Skip to content

Pages/ViewModel Lifecycle #3

@aritchie

Description

@aritchie

.AddSingleton<ArticleContent>()

I repeatedly see customers tripping on issues due to keeping pages in memory even after the page is removed from a navigation stack. If a page is truly "single" because it sits at the bottom of the navigation stack like a mainpage/tabbedpage, it will make no difference if the page is transient or singleton. It will already be pinned. However, when it comes to something like an entry form, you don't want state like that hanging around. I've seen users writing custom (and sometimes long) "Clear" methods.

For your app, the use of singleton works, but since this is a workshop and you're educating users, I wanted to raise this as a potential point. Users will keep "swinging the hammer" on using singleton where most often - it is not valid in big applications.

Would like to hear your thoughts on this. Happy to submit a PR if you see value in this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions