Home Reference Source Test
public class | source

StateHolder

Base class for manipulating state.

Constructor Summary

Public Constructor
public

Creates a new state holder object.

Member Summary

Public Members
public
public

state: *

Method Summary

Public Methods
public

Deletes given state values.

public

Runs all registered callbacks passing the object itself.

public

Returns the initial state for the object.

public

getState(path: Array): any

Returns the state or the requested property.

public

mergeState(path: Array, value: any)

Merges given state values.

public

register(callback: Function, context: Object, trace: Error): Function

Registers a callback to be executed at every state change.

public

Restores the state to the initial state.

public

setState(path: Array, value: any)

Sets given state values.

public

unregister(callback: Function)

Removes a callback previously registered.

public

updateState(path: Array, callback: Function)

Updates state values.

Public Constructors

public constructor source

Creates a new state holder object.

Public Members

public callbacks: * source

public state: * source

Public Methods

public deleteState(path: Array) source

Deletes given state values.

Params:

NameTypeAttributeDescription
path Array

to the state value

public emitChange() source

Runs all registered callbacks passing the object itself.

public getInitialState(): Object source

Returns the initial state for the object.

Return:

Object

state

public getState(path: Array): any source

Returns the state or the requested property.

Params:

NameTypeAttributeDescription
path Array

to the wanted state property

Return:

any

value

public mergeState(path: Array, value: any) source

Merges given state values.

Params:

NameTypeAttributeDescription
path Array

to the state value

value any

public register(callback: Function, context: Object, trace: Error): Function source

Registers a callback to be executed at every state change.

Params:

NameTypeAttributeDescription
callback Function

to be registered

context Object

this variable for the callback

trace Error

error

Return:

Function

callback added callback

public resetState() source

Restores the state to the initial state.

public setState(path: Array, value: any) source

Sets given state values.

Params:

NameTypeAttributeDescription
path Array

to the state value

value any

public unregister(callback: Function) source

Removes a callback previously registered.

Params:

NameTypeAttributeDescription
callback Function

to be removed

public updateState(path: Array, callback: Function) source

Updates state values.

Params:

NameTypeAttributeDescription
path Array

to the state value

callback Function

to return new state value