new Store(options, data)
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
options |
Object |
<optional> |
Class options. |
data |
* |
<optional> |
Class data |
- Source:
Extends
Methods
-
clear()
-
Removes all keys from store.
- Source:
-
destroy()
-
Destroys the object. Emits the following events before and after the object is destroyed. Sets data and options to null and calls the
dispose
anddisposeInternal
on parent to make a proper clean up. Callingdispose
will set theObject.isDisposed
to true and callingdisposeInternal
will unlisten all binded events so there won't be any event and/or memory leak.- Inherited From:
- Source:
-
emit(eventName, data)
-
Dispatches an event and calls all listeners listening for events of this event. See also goog.events.Listenable.prototype.dispatchEvent
Parameters:
Name Type Argument Description eventName
string Name of the event.
data
* <optional>
Data which will passed to listeners
- Inherited From:
- Source:
-
freeze()
-
Freezes object to prevent adding new properties, updating or deleting existing properties.
- Inherited From:
- Source:
-
get(key, escape) → {*}
-
Returns value of the given key from the store. String values will be encoded by default to prevent possible XSS attacks. If you don't want the encoding for some reason pass a second
false
parameter.Parameters:
Name Type Argument Description key
string Key to be returned.
escape
boolean <optional>
Whether you want to espace the value or not.
- Source:
Returns:
- Type
- *
-
getData() → {*}
-
Returns class data.
- Inherited From:
- Source:
Returns:
Class data.
- Type
- *
-
getKeys() → {Array}
-
Returns keys array.
- Source:
Returns:
Keys array.
- Type
- Array
-
getOption() → {*}
-
Returns value of a key in options object.
- Inherited From:
- Source:
Returns:
Value of key or null.
- Type
- *
-
getOptions() → {Object}
-
Returns all options object.
- Inherited From:
- Source:
Returns:
Options object.
- Type
- Object
-
getUid() → {string}
-
Return unique id.
- Inherited From:
- Source:
Returns:
Unique id of this component.
- Type
- string
-
getValues() → {Array}
-
Returns values array.
- Source:
Returns:
Values array.
- Type
- Array
-
has(key) → {boolean}
-
Returns
true
if the store has the given key.Parameters:
Name Type Description key
string Key to be searched in store.
- Source:
Returns:
Whether the store has the key or not.
- Type
- boolean
-
isDestroyed() → {boolean}
-
Returns the object's destroy state.
- Inherited From:
- Source:
Returns:
Whether the object is destroyed or not.
- Type
- boolean
-
off(eventName, callback) → {boolean}
-
Removes an event listener which was added with @on or @once. See also goog.events.Listenable.prototype.unlisten
Parameters:
Name Type Description eventName
string Name of the event.
callback
function Callback function for the event.
- Inherited From:
- Source:
Returns:
Whether any listener was removed.
- Type
- boolean
-
on(eventName, callback) → {goog.events.ListenableKey|number}
-
Adds an event listener. See also goog.events.Listenable::listen
Parameters:
Name Type Description eventName
string Name of the event.
callback
function Callback function for the event.
- Inherited From:
- Source:
Returns:
Unique key for the listener.
- Type
- goog.events.ListenableKey | number
-
once(eventName, callback) → {goog.events.ListenableKey|number}
-
Adds an event listener that is removed automatically after the listener fired once. See also goog.events.Listenable.prototype.listenOnce
Parameters:
Name Type Description eventName
string Name of the event.
callback
function Callback function for the event.
- Inherited From:
- Source:
Returns:
Unique key for the listener.
- Type
- goog.events.ListenableKey | number
-
set(key, value) → {boolean}
-
Sets a new key value pair into store. It will also make a validation before setting the new value. If you set a validation rule in options.validations for that property, when validation failed, the property won't be updated. Store::set will return no and emit a 'PropertyRejected' event otherwise it will return true and it will also emit 'ProperySet'. Both events will include key and value. If the key and value passed to set does not related with a validation rule, it will directly set to store. This makes validation optional.
Parameters:
Name Type Description key
string Key to be returned.
value
* Value of the key.
- Source:
Returns:
Whether the set is completed or not.
- Type
- boolean
-
setData(data)
-
Sets data of this class.
Parameters:
Name Type Description data
* Data passed to class.
- Inherited From:
- Source:
-
setOptions(options)
-
Sets options object of this class.
Parameters:
Name Type Description options
Object Options object.
- Inherited From:
- Source:
-
<private> setUid_()
-
Sets uid.
- Inherited From:
- Source:
-
toObject() → {Object}
-
Returns the current data as object.
- Source:
Returns:
Store data.
- Type
- Object
-
unset(key) → {boolean}
-
Removes a key from strore.
Parameters:
Name Type Description key
string Key to be removed.
- Source:
Returns:
Whether the key removed or not.
- Type
- boolean
-
validate(key, value) → {boolean}
-
Validates the given value for given key's validation rules.
Parameters:
Name Type Description key
string Key to be validated.
value
* Value of the key to validate.
- Source:
Returns:
Whether the validation is passed or failed.
- Type
- boolean
-
validateAll()
-
Validates all data and throw an error if validation fails.
- Source: