goog.ds.DataManager
Classgoog.ds.DataManager
> goog.ds.DataNode
goog.ds.DataManager()
Create a DataManger
.addDataSource(ds, opt_autoload, opt_name)
Add a data source
ds
{goog.ds.DataNode
}
opt_autoload
{boolean
=}
opt_name
{string
=}
.addIndexedListener(fn, dataPath, 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
fn
{Function
}
dataPath
{string
}
opt_id
{string
=}
.addListener(fn, dataPath, 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
fn
{Function
}
dataPath
{string
}
opt_id
{string
=}
.aliasDataSource(name, 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.
name
{string
}
dataPath
{string
}
.clearInstance()
Clears the global instance (for unit tests to reset state).
.fireDataChange(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
dataPath
{string
}
.get(var_args)
Get the value of the node
var_args
{...?}
Object
}
.getChildNode(name)
Gets a named child node of the current node
name
{string
}
goog.ds.DataNode
}
.getChildNodeValue(name)
Gets the value of a child node
name
{string
}
.getChildNodes(opt_selector)
Gets all of the child nodes of the current node. Should return an empty DataNode list if no child nodes.
opt_selector
{string
=}
goog.ds.DataNodeList
}
.getDataName()
Get the name of the node relative to the parent node
string
}
.getDataPath()
Gets the a qualified data path to this node
string
}
.getDataSource(name)
Gets a named child node of the current node.
name
{string
}
goog.ds.DataNode
}
.getEventCount()
Get the total count of events fired (mostly for debugging)
number
}
.getInstance()
Get the global instance
goog.ds.DataManager
}
.getListenerCount()
Get the total number of listeners (per expression listened to, so may be more than number of times addListener() has been called
number
}
.getLoadState()
Gets the state of the backing data for this node
goog.ds.LoadState
}
.isList()
Whether the value of this node is a homogeneous list of data
boolean
}
.load()
Load or reload the backing data for this node only loads datasources flagged with autoload
.removeIndexedListeners(fn, opt_dataPath, opt_id)
Removes indexed listeners with a given callback function, and optional matching datapath and matching id.
fn
{Function
}
opt_dataPath
{string
=}
opt_id
{string
=}
.removeListeners(fn, opt_dataPath, opt_id)
Removes listeners with a given callback function, and optional matching dataPath and matching id
fn
{Function
}
opt_dataPath
{string
=}
opt_id
{string
=}
.runWithoutFiringDataChanges(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.
callback
{Function
}
.set(value)
Set the value of the node
value
{*}
.setChildNode(name, value)
Inherited from goog.ds.DataNode
.
Sets a named child node of the current node.
name
{string
}
value
{Object
}
Object
}
.setDataName(name)
Inherited from goog.ds.DataNode
.
Set the name of the node relative to the parent node
name
{string
}