ds.DataManager Extends goog.ds.DataNode
Create a DataManger

Inheritance

Constructor

goog.ds.DataManager()

Instance Methods

Public Protected Private
addDataSource(dsopt_autoloadopt_name)
Add a data source
Arguments:
ds : goog.ds.DataNode
The data source.
opt_autoload : boolean=
Whether to automatically load the data, defaults to false.
opt_name : string=
Optional name, can also get name from the datasource.
code »
addIndexedListener(fndataPathopt_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
Arguments:
fn : Function
Callback function, signature (dataPath, id, indexes).
dataPath : string
Fully qualified data path.
opt_id : string=
A value passed back to the listener when the dataPath is matched.
code »
addListener(fndataPathopt_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
Arguments:
fn : Function
Callback function, signature function(dataPath, id).
dataPath : string
Fully qualified data path.
opt_id : string=
A value passed back to the listener when the dataPath is matched.
code »
aliasDataSource(namedataPath)
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.
Arguments:
name : string
Alias name, must be a top level path ($Foo).
dataPath : string
Data path being aliased.
code »
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
Arguments:
dataPath : string
Fully qualified data path.
code »
get() !Object
Get the value of the node
Returns: !Object  The value of the node.
code »
getChildNode(name) goog.ds.DataNode
Gets a named child node of the current node
Arguments:
name : string
The node name.
Returns: goog.ds.DataNode  The child node, or null if no node of this name exists.
code »
getChildNodeValue()
No description.
code »
getChildNodes()
No description.
code »
getDataName() string
Get the name of the node relative to the parent node
Returns: string  The name of the node.
code »
getDataPath() string
Gets the a qualified data path to this node
Returns: string  The data path.
code »
getDataSource(name) goog.ds.DataNode
Gets a named child node of the current node.
Arguments:
name : string
The node name.
Returns: goog.ds.DataNode  The child node, or null if no node of this name exists.
code »
getEventCount() number
Get the total count of events fired (mostly for debugging)
Returns: number  Count of events.
code »
getListenerCount() number
Get the total number of listeners (per expression listened to, so may be more than number of times addListener() has been called
Returns: number  Number of listeners.
code »
getLoadState() goog.ds.LoadState
Gets the state of the backing data for this node
Returns: goog.ds.LoadState  The state.
code »
isList() boolean
Whether the value of this node is a homogeneous list of data
Returns: boolean  True if a list.
code »
listenForAlias_(dataPathname)
Listener function for matches of paths that have been aliased. Fires a data change on the alias as well.
Arguments:
dataPath : string
Path of data event fired.
name : string
Name of the alias.
code »
load()
Load or reload the backing data for this node only loads datasources flagged with autoload
code »
removeIndexedListeners(fnopt_dataPathopt_id)
Removes indexed listeners with a given callback function, and optional matching datapath and matching id.
Arguments:
fn : Function
Callback function, signature function(dataPath, id).
opt_dataPath : string=
Fully qualified data path.
opt_id : string=
A value passed back to the listener when the dataPath is matched.
code »
removeListeners(fnopt_dataPathopt_id)
Removes listeners with a given callback function, and optional matching dataPath and matching id
Arguments:
fn : Function
Callback function, signature function(dataPath, id).
opt_dataPath : string=
Fully qualified data path.
opt_id : string=
A value passed back to the listener when the dataPath is matched.
code »
removeListenersByFunction_(listenersByFunctionindexedfnopt_dataPathopt_id)
Removes listeners with a given callback function, and optional matching dataPath and matching id from the given listenersByFunction data structure.
Arguments:
listenersByFunction : Object
The listeners by function.
indexed : boolean
Indicates whether the listenersByFunction are indexed or not.
fn : Function
Callback function, signature function(dataPath, id).
opt_dataPath : string=
Fully qualified data path.
opt_id : string=
A value passed back to the listener when the dataPath is matched.
code »
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.
Arguments:
callback : Function
Zero-arg function to execute.
code »
set()
No description.
code »
get(var_args) *
Get the value of the node
Arguments:
var_args : ?...
Do not check arity of arguments, because some subclasses require args.
Returns: *  The value of the node, or null if no value.
code »
getChildNode(nameopt_canCreate) goog.ds.DataNode
Gets a named child node of the current node
Arguments:
name : string
The node name.
opt_canCreate : boolean=
Whether to create a child node if it does not exist.
Returns: goog.ds.DataNode  The child node, or null if no node of this name exists.
code »
getChildNodeValue(name) *
Gets the value of a child node
Arguments:
name : string
The node name.
Returns: *  The value of the node, or null if no value or the child node doesn't exist.
code »
getChildNodes(opt_selector) !goog.ds.DataNodeList
Gets all of the child nodes of the current node. Should return an empty DataNode list if no child nodes.
Arguments:
opt_selector : string=
String selector to choose child nodes.
Returns: !goog.ds.DataNodeList  The child nodes.
code »
getDataName() string
Get the name of the node relative to the parent node
Returns: string  The name of the node.
code »
getDataPath() string
Gets the a qualified data path to this node
Returns: string  The data path.
code »
getLoadState() goog.ds.LoadState
Gets the state of the backing data for this node
Returns: goog.ds.LoadState  The state.
code »
isList() boolean
Whether the value of this node is a homogeneous list of data
Returns: boolean  True if a list.
code »
set(value)
Set the value of the node
Arguments:
value : *
The new value of the node.
code »
setChildNode(namevalue) Object
Sets a named child node of the current node.
Arguments:
name : string
The node name.
value : Object
The value to set, can be DataNode, object, property, or null. If value is null, removes the child node.
Returns: Object  The child node, if the node was set.
code »
setDataName(name)
Set the name of the node relative to the parent node
Arguments:
name : string
The name of the node.
code »

Instance Properties

aliases_ :
No description.
Code »
autoloads_ : goog.structs.Map
No description.
Code »
constructor :
No description.
Code »
dataSources_ : goog.ds.BasicNodeList
No description.
Code »
eventCount_ :
No description.
Code »
indexedListenersByFunction_ :
No description.
Code »
listenerMap_ :
No description.
Code »
listenersByFunction_ :
No description.
Code »
load :
Load or reload the backing data for this node
Code »

Static Methods

goog.ds.DataManager.clearInstance()
Clears the global instance (for unit tests to reset state).
code »
goog.ds.DataManager.getInstance() !goog.ds.DataManager
Get the global instance
Returns: !goog.ds.DataManager  The data manager singleton.
code »

Static Properties

goog.ds.DataManager.instance_ : goog.ds.DataManager
Global instance
Code »
goog.ds.DataManager.superClass_ :
No description.
Code »

Package ds

Package Reference