GithubHelp home page GithubHelp logo

Comments (3)

JerryNixon avatar JerryNixon commented on May 22, 2024

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.

pekspro avatar pekspro commented on May 22, 2024

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.

JerryNixon avatar JerryNixon commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.