Comments (3)
First, thanks for the question.
Keep your life simple, don't use the Suspension Manager, just persist your view models to file whenever you hit a checkpoint. Is it when the user does something? Is it when you navigate to a new page? Only you can determine the correct checkpoints. You should use the OnNavigatedFrom in your view models to verify that you have saved your state, this is global insofar as the app-level deferral. This does not, however, give you more then the 5 seconds any app is allowed to suspend.
To that end, the checkpoints help your app save more frequently along-the-way so you can be successful when you suspend. Having different view models as properties of another view model is a common practice and there is nothing wrong with that. It's also nice because your view model repository is easily reused because you are not creating something new. Moreover, it doesn't matter if this is a static singleton or not; this approach is universally the same for every app.
Now, to your point. The template could share global objects in a lot of different ways, but I think you would be disappointed how it would be implemented. That's because the way App 1 (not your app) needs to share across is far more complicated than the way your app does, and so you have considerable overhead to use a "generic" solution than that simple implementation you are enjoying right now. What's wrong with creating a GlobalObjects class with a bunch of static properties? Nothing, and its elegance is in its simplicity. Do you need a template for that? No.
That being said, I would be open to a pull request if you wanted to suggest something. But I recommend that unless you already have a universal solution in mind, that you take my advice and enjoy your own solution and let developers simply solve this themselves on a one-off basis. //Jerry
from template10.
Thanks for answering :-).
I think you have some really good points (and the code you posted on StackOverflow was starting me thinking).
In my case I have relative small objects so the 5 seconds limit shouldn’t be a problem. So far that a generic solution will be fine. But a generic solution could clearly be misused so I’m not sure if that is an good idea after all .
Either way, I plan to port my app to Windows 10 in a while. Then I will have a deeper look on this.
(Finally, I just want to thank for your videos on MVA – they are excellent :-)
from template10.
Cheers.
From: pekspro [mailto:[email protected]]
Sent: Thursday, May 28, 2015 11:41 PM
To: Windows-XAML/Template10
Cc: Jerry Nixon
Subject: Re: [Template10] Handling global objects and suspension (#1)
Thanks for answering :-).
I think you have some really good points (and the code you posted on StackOverflow was starting me thinking).
In my case I have relative small objects so the 5 seconds limit shouldn’t be a problem. So far that a generic solution will be fine. But a generic solution could clearly be misused so I’m not sure if that is an good idea after all J.
Either way, I plan to port my app to Windows 10 in a while. Then I will have a deeper look on this.
(Finally, I just thank for your videos on MVA – they are excellent :-)
—
Reply to this email directly or view it on GitHub #1 (comment) .
from template10.
Related Issues (20)
- Discussion: How to handle Background Tasks. HOT 1
- Unable load T10 project form GitHub HOT 13
- Add ToUri() to the PathBuilder HOT 4
- Navigation Services Not working HOT 1
- Reconsider if ViewModelBase should implement NavigationService HOT 1
- Why haven't we implemented auto-discover for Nav/Pages? HOT 1
- Confirm revert projects back to UWP Class Library
- Misleading information about Prism HOT 1
- Misleading exception while failing to deserialize an argument is passed in Navigation Service HOT 1
- Xaml exception (suddenly, without history) HOT 2
- AttachGestures should have an override without Window
- Add Nav extensions off Page types HOT 1
- GestureService shouldn't handle the BackRequested from SystemNavigationManager
- Exception handling in SettingsService HOT 3
- How can I use Navigation Service without Template 10 Bootstrapper? HOT 2
- Any news about future? HOT 1
- I need access to old Nuget packages HOT 1
- Update to reference latest version of Newtonsoft.Json library HOT 2
- Windows 10
- Template 10 ellipsis collapsed error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from template10.