Classes
Members
(inner, constant) eventTypes :string
Types of events a store can fire.
Properties:
Name | Type | Description |
---|---|---|
CREATED |
string
|
created |
STATE_CHANGE |
string
|
statechange |
VALIDATION_FAIL |
string
|
validationfail |
- Source:
Type:
-
string
(inner, readonly) handlers :Object.<string, function()>
Get current state handlers.
Set handlers property after initialization using StateStoreInstance.setHandler
.
- Source:
Type:
-
Object.<string, function()>
(inner, readonly) model :Object.<string, (String|Array|function())>
Get current state model fields
.
- Source:
Type:
-
Object.<string, (String|Array|function())>
(inner) onStateChange :function
Called after state modification.
- Source:
Type:
-
function
(inner) onValidationFail :function
Called when a value fails validation test.
- Source:
Type:
-
function
(inner, readonly) state :Object.<string, any>
Get current state values.
To set store inner state object use instead StateStoreInstance.setState
.
- Source:
Type:
-
Object.<string, any>
Methods
(inner) clearState(stateObjopt, callbackopt)
Unset all state properties by default, if a stateObj is given replace current state obj with the provided stateObj.
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
stateObj |
Object.<string, any>
|
<optional> |
{} |
values the store should be reset to |
callback |
function
|
<optional> |
function called after the store has been cleared |
(inner) off(event, fn)
Remove a listener. See eventTypes
for the complete list of events.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
event |
String
|
|
fn |
function
|
(inner) on(event, fn)
Add a listener. See eventTypes
for the complete list of events.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
event |
String
|
|
fn |
function
|
(inner) setHandler(state, handler)
Set state property handler function.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
state |
String
|
|
handler |
function
|
(inner) setModelField(field, model)
Set a model field property.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
field |
String
|
|
model |
String
|
Array
|
function
|
(inner) setState(stateObj, callbackopt)
Set new state value if validation is successful
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
stateObj |
Object.<string, any>
|
||
callback |
function
|
<optional> |
(inner) toggleShallowValidation() → {Boolean}
Toggle stateStore.model.shallow
property
- Source:
Returns:
- Type:
-
Boolean
model new shallow value
(inner) unsetHandler(state)
Unset state property handler function.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
state |
String
|
(inner) unsetModelField(field)
Unset an existing model field.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
field |
String
|
Type Definitions
StateChangeObj
Properties:
Name | Type | Description |
---|---|---|
oldValue |
any
|
state previous value |
value |
any
|
state current value |
- Source:
Type:
-
Object
StateStoreInit
Properties:
Name | Type | Attributes | Default | Description | |||||
---|---|---|---|---|---|---|---|---|---|
namespace |
String
|
<optional> |
"" | ||||||
state |
Object.<string, any>
|
<optional> |
{} | initial state object |
|||||
model |
Object.<string, (string|Array|function())>
|
<optional> |
initial model validation object |
||||||
handlers |
Object.<string, function()>
|
||||||||
onStateChange |
function
|
callback function called on each state change |
|||||||
onValidationFail |
function
|
callback function called when a state update is rejected because of model validation fail |
|||||||
modelOptions |
Object
|
||||||||
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
shallowValidation |
Boolean
|
<optional> |
false |
- Source:
Type:
-
Object