jQuery/JS SPA Framework - StateManager
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.
Methods
Name | Description |
---|---|
addStateSource(stateSource) |
Adds an object that implements an interface of a state source to the state manager's collection of state sources. |
clearState() |
Removes the application state that has been saved by the saveState() method to the state storage. |
removeStateSource(stateSource) |
Removes a specified state source from the state manager's collection of state sources. |
restoreState() |
Restores the application state that has been saved by the saveState() method to the state storage. |
saveState() |
Saves the current application state. |
If you have technical questions, please create a support ticket in the DevExpress Support Center.