|
.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.
MauiWorkshop/src/MyNewsReader/MauiProgram.cs
Line 38 in 155283e
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.