model.wire(dependencies, fn[, thisArg])
dependencies
An array of dependency properties.
These are property names in the Backbone model.
This can also be a single string in the case of
having only one dependency property.
fn
The callback function that will be invoked with
current values for each dependency property as arguments
in the order specified by dependencies
.
This function will be invoked:
fn
will not be invoked unless all dependency property
values have been defined (if any property values are
undefined
, fn
will not be invoked).
thisArg
(optional) The object used as this
when invoking fn
.
Note that fn
is invoked on the next tick of the JavaScript
event loop, both for initialization and for dependency property updates.
Note also that sequential changes to multiple dependency properties
result in only a single invocation of fn
.
wire
is added to the prototype of Backbone.Model
, so it can be
invoked as model.wire()
on any Backbone model.
Backbone.Model.prototype.wire = function (dependencies, fn, thisArg){