State

State

Creates state managers.

Constructor

new State($data)

Description:
  • Creates a new state manager.
Source:
Example
const state = new State(data);
Parameters:
Name Type Description
$data T The data state to store.

Methods

getState() → {T}

Description:
  • Gets the data state.
Source:
Returns:
Type
T

setState($data)

Description:
  • Sets the data state.
Source:
Parameters:
Name Type Description
$data T The data state to set.

unwatchAll()

Description:
  • Removes all watchers of the data state changes.
Source:

unwatchState($handler)

Description:
  • Removes a watcher of the data state changes.
Source:
Parameters:
Name Type Description
$handler typewatcherstate The state changing handler to detach.

watchState($handler)

Description:
  • Adds a watcher for the data state changes.
Source:
Parameters:
Name Type Description
$handler typewatcherstate The state changing handler to attach.

Type Definitions

(protected) typewatcherstate($state) → {void}

Source:
Parameters:
Name Type Description
$state T The new data state.
Returns:
Type
void