SPA Framework StateManager

An object used to store the current application state.

Type: Object

In an application, there can be different information that should be saved and restored when required, e.g., when the application is closed and then opened. For instance, the current navigation history should be saved when closing the application so that the last displayed view is displayed again when reopening the application. Thus, the navigation manager implements special methods that characterize it as a state source. As there can be several state sources in an application, the application should have a state manager that "knows" about all of them and calls their methods to save/restore their states.

The StateManager object has a collection of state sources that should be notified when a request to save/restore the current state arrives. By default, only the navigation manager is added to this collection. To add another state source to this collection, use the state manager's addStateSource(stateSource) method. You can remove a state source from this collection when required by using the removeStateSource(stateSource) method.

When the HtmlApplication requests to save/clear/restore the application state, the StateManager object calls the saveState()/restoreState()/clearState() method, in which the corresponding method of each of the "known" state sources is called.

By default, the session storage is used as a state storage. You can use another storage specifying it using the stateStorage option of the HtmlApplication object.


This section describes configuration options used to create a StateManager object.


This section describes the methods used to manipulate the application state.