Class: Store

@aofl/store/legacy~ Store

Store is a built on the same principles as redux and attempts to simplify some of Redux's concepts. It also incorporates ideas from other centralized state management implementations.

new Store(debug)

Creates an instance of Store.
Parameters:
Name Type Description
debug Boolean
Deprecated:
  • Yes
Source:

Methods


addDecorators(decorators)

addDecorators() adds an array decorators to the docorators list and calls forceCommit to invoke the newly added decorators.
Parameters:
Name Type Description
decorators Array
Source:

addState(sdo, payload)

addState() adds an sdo to the store and invokes the SDO.mutations.init() method to set the initial state of the sub-state. Additionaly a payload can be supplied to the init funciton to instantiate the sub-state with a modifed inital state.
Parameters:
Name Type Description
sdo Object
payload *
Source:

commit(mutations, forceCommit)

commit() accepts variadit mutation objects as arguments and applies the mutations agains the current state to generate the next state of the application.
Parameters:
Name Type Argument Description
mutations * <repeatable>
forceCommit *
Source:
Throws:
TypeError

forceCommit()

forceCommit() applies decorators and asyncMutations against the current state and executes subscribed callback functions even if state did not change.
Source:

getState()

getState() return the current state.
Source:
Returns:
Type
Object

replaceState(state)

replaceState() take a state object, replaces the state property and notifies subscribers.
Parameters:
Name Type Description
state Object
Source:

subscribe(callback)

subscribe() register the callback function with registerCallbackInstance and returns the unsubscribe function.
Parameters:
Name Type Description
callback Furtion
Source:
Returns:
Type
function