Best practices in creating a persistent app state?


#1

How do people manage to mimic a native app’s state when the user closes, or minimizes the app?

This would include:

  1. remaining signed in until logging out manually

  2. remain signed in after a crash

  3. keeping the focus of certain pages the same when minimized

there are probably others but these are just a few to name that are important.


#2

bump.

any thoughts on this from anyone?


#3

Seems to me caching your local user object into a localStorage object is the best way to go, that’s what I’m doing.

When the app starts you can have it look for an object in the localStorage and assign it to the scope on load. Then, see if the conditions for login are met (username/key etc) and off you go.

You can create a service to handle your user/authentication requests which always writes to the local store first, then reloads from the storage on each major update.