Home

# Class goog.ds.DataManager

Create a DataManger

extends goog.ds.DataNode

Instance Method Summary
| `addDataSource(?goog.ds.DataNode ds, boolean= opt_autoload, string= opt_name)` Add a data source

`addIndexedListener(?Function fn, string dataPath, string= opt_id)`

Adds an indexed listener. Indexed listeners allow for '*' in data paths. If a * exists, will match all values and return the matched values in an array to the callback. Currently uses a promiscuous match algorithm: Matches everything before the first '*', and then does a regex match for all of the returned events. Although this isn't optimized, it is still an improvement as you can collapse 100's of listeners into a single regex match

| `addListener(?Function fn, string dataPath, string= opt_id)` Adds a listener Listeners should fire when any data with path that has dataPath as substring is changed. TODO(user) Look into better listener handling
| `aliasDataSource(string name, string dataPath)` Create an alias for a data path, very similar to assigning a variable. For example, you can set $CurrentContact -> $Request/Contacts[5], and all references to $CurrentContact will be procesed on $Request/Contacts[5]. Aliases will hide datasources of the same name.

`fireDataChange(string dataPath)`

Fire a data change event to all listeners If the path matches the path of a listener, the listener will fire If your path is the parent of a listener, the listener will fire. I.e. if $Contacts/bob@bob.com changes, then we will fire listener for $Contacts/bob@bob.com/Name as well, as the assumption is that when a parent changes, all children are invalidated. If your path is the child of a listener, the listener may fire, depending on the ancestor depth. A listener for $Contacts might only be interested if the contact name changes (i.e. $Contacts doesn't fire on $Contacts/bob@bob.com/Name), while a listener for a specific contact might (i.e. $Contacts/bob@bob.com would fire on $Contacts/bob@bob.com/Name). Adding "/..." to a lisetener path listens to all children, and adding "/*" to a listener path listens only to direct children

| `get() ⇒ ?Object` Get the value of the node
| `getChildNode(string name) ⇒ ?goog.ds.DataNode` Gets a named child node of the current node
| `getChildNodeValue(string name) ⇒ ?Object` Gets the value of a child node
| `getChildNodes(string= opt_selector) ⇒ ?goog.ds.DataNodeList` Gets all of the child nodes of the current node.
| `getDataName() ⇒ string` Get the name of the node relative to the parent node
| `getDataPath() ⇒ string` Gets the a qualified data path to this node
| `getDataSource(string name) ⇒ ?goog.ds.DataNode` Gets a named child node of the current node.
| `getEventCount() ⇒ number` Get the total count of events fired (mostly for debugging)
| `getListenerCount() ⇒ number` Get the total number of listeners (per expression listened to, so may be more than number of times addListener() has been called
| `getLoadState() ⇒ ?goog.ds.LoadState` Gets the state of the backing data for this node
| `isList() ⇒ boolean` Whether the value of this node is a homogeneous list of data
| `listenForAlias_(string dataPath, string name)` Listener function for matches of paths that have been aliased. Fires a data change on the alias as well.
| `load()` Load or reload the backing data for this node only loads datasources flagged with autoload
| `removeIndexedListeners(?Function fn, string= opt_dataPath, string= opt_id)` Removes indexed listeners with a given callback function, and optional matching datapath and matching id.
| `removeListeners(?Function fn, string= opt_dataPath, string= opt_id)` Removes listeners with a given callback function, and optional matching dataPath and matching id
| `removeListenersByFunction_(?Object listenersByFunction, boolean indexed, ?Function fn, string= opt_dataPath, string= opt_id)` Removes listeners with a given callback function, and optional matching dataPath and matching id from the given listenersByFunction data structure.
| `runWithoutFiringDataChanges(?Function callback)` Disables the sending of all data events during the execution of the given callback. This provides a way to avoid useless notifications of small changes when you will eventually send a data event manually that encompasses them all. Note that this function can not be called reentrantly.
| `set(?Object value)` Set the value of the node

Static Method Summary
| `clearInstance()` Clears the global instance (for unit tests to reset state).
| `getInstance() ⇒ ?goog.ds.DataManager` Get the global instance