State

State

Functions

object init ()
object get ()
object set ()
object exclude ()
any trigger ()
number connect ()
disconnect ()
destroy ()

Functions

init ()

object
init (object   state,
      array    listeners);

Constructor function

Parameters

state

The applet that contains the context menu.

 

listeners

The orientation of the applet.

 

Returns

The public API with state. key (string|null): The key to get from the state object.


get ()

object
get ();

Passing null or an asterisk will retrieve the entire state object. Passing keys with dot notation will return the corresponding object path. E.g., "bar.foo".

Returns

The cloned object.


set ()

object
set (object    object,
     boolean   forceDispatch);

Copies a keyed object back into state, and calls dispatch to fire any connected callbacks.

Parameters

object

The object to assign into state.

 

forceDispatch

Whether or not to force dispatching of callbacks from any connected listeners on object's keys. By default, this only occurs if the state has actually changed as a result of setting.

 

Returns

The public API for chaining.


exclude ()

object
exclude (array   excludeKeys);

Parameters

excludeKeys

Array of string keys.

 

Returns

The public API with filtered state.


trigger ()

any
trigger ();

Fires a callback event for any matching keys in the listener queue. It supports passing through unlimited arguments to the callback. Useful for setting up actions.

Returns

Return result of the callback. actions (string|array|object): Actions


connect ()

number
connect (function   callback);

Parameters

callback

The function to be invoked on either state property change, or through the trigger method.

 

Returns

The connection ID to use for later disconnection.


disconnect ()


disconnect (string   key);

Removes a callback listener from the queue.

Parameters

key

The ID to disconnect.

 

destroy ()


destroy ();

Assigns undefined to all state properties and listeners. Intended to be used at the end of the application life cycle.