React SPA Framework - StateManager - Methods

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

addStateSource(stateSource)

Adds an object that implements an interface of a state source to the state manager's collection of state sources.

Parameters:
stateSource:

Object

An object that has the saveState(storage), restoreState(storage) and removeState(storage) methods to manipulate a particular state in the application.

To manipulate the application's state, the state manager passes the requests received from the HtmlApplication object to the state sources that are collected using the addStateSource(stateSource) method. The state sources must have the following methods.

  • saveState(storage)
  • restoreState(storage)
  • removeState(storage)

To remove a state source from the state manager's collection, use the removeStateSource(stateSource) method.

clearState()

Removes the application state that has been saved by the saveState() method to the state storage.

The saved application state is not restored after the clearState() method is called.

This method passes the request to clear the saved state to all the state sources that are "known" to the state manager.

removeStateSource(stateSource)

Removes a specified state source from the state manager's collection of state sources.

Parameters:
stateSource:

Object

An object that has been added to the collection using the addStateSource(stateSource) method.

restoreState()

Restores the application state that has been saved by the saveState() method to the state storage.

Use this method to restore the current application state when required, e.g., when the application is recreated. This method passes the request to restore the saved state to all the state sources that are "known" to the state manager.

NOTE
By default, the HtmlApplication object calls this method during its initialization so that the previously saved state is restored, in case anything was saved.

saveState()

Saves the current application state.

Use this method to save the current application state when required, e.g., when the application is closed. This method passes the request to save the current state to all the state sources that are "known" to the state manager.

NOTE
This method is called in the DevExtreme Basic Application and Multi-Channel Application templates provided by Visual Studio.