# Namespace: globalState

## globalState

Manage a global object that allow storing and sharing values among modules.

### Example

    // Use the default storage
    globalState.set( 'PROP', 'VALUE' );
    globalState.get( 'PROP' );

    // Use a storage with a specific name
    globalState.set( 'MY_STORE', 'PROP', 'VALUE' );
    globalState.get( 'MY_STORE', 'PROP' );

    // To use events on properties change
    globalState.activeEventsDispatch();
    globalState.registerOnEveryChange( (value, propertyName, storeName) => {} )
    globalState.registerOnStoreChange( (value, propertyName, storeName) => {}, 'storeName' )
    globalState.registerOnPropertyChange( (value, propertyName, storeName) => {}, 'storeName', 'myProperty' )

### Members

#### DEFAULT_STORE_NAME :String

  Name of the default store

  ##### Type:

  - String

### Methods

#### activeEventsDispatch(alwaysDispatch)

  Active the dispatch of events when a property is change

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `alwaysDispatch` | Boolean | If true, it will dispatch events even if the value in the store is the same as the value you try to set

#### get(arg1, arg2)

  Get the value of a property. If there are only 2 arguments, the default store will be used.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `arg1` | String | Store ( or Property if 1 arguments are passed )
  `arg2` | String | Property if 2 arguments are passed

  ##### Returns:

  Type
    *

#### registerOnEveryChange(callback)

  Bind a function to be called on all properties change

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | GlobalState_callback |

#### registerOnPropertyChange(callback, storeName, propertyName)

  Bind a function to be called on a specific property change in a specific store

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | GlobalState_callback |
  `storeName` | String |
  `propertyName` | String |

#### registerOnStoreChange(callback, storeName)

  Bind a function to be called on all properties change for a specific store

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | GlobalState_callback |
  `storeName` | String |

#### remove(callback)

  Unbind the registered function from all change events

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `callback` | function |

#### set(arg1, arg2, value)

  Set a value in a property. If there are only 2 arguments, the default store will be used

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `arg1` | String | Store ( or Property if 2 arguments are passed )
  `arg2` | * | Property ( or Value if 2 arguments are passed )
  `value` | * | Value if 3 arguments are passed

  ##### Returns:

  - Return the setted value
  Type
    *

#### stopEventsDispatch()

  Stop the dispatch of events

### Type Definitions

#### GlobalState_callback()

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `value` | * |
  `properyName` | String |
  `storeName` | String |

#### Search results