Key-value coding for javascript objects. Gives access to values in object trees
via keypaths. Emits update events as they come, with
minimal changesets. Good for finding deltas for new
versions of objects, and linking views to models.
-
(constructor)([< object >options])
Creates and returns a new KVCObject.
Valid options:
- delimiter - string - The string to use as delimiter between keys.
Default: '.'
-
setObject(< object >object, [< bool >silent]) - (void)
Sets the current root, overwriting the existing root. If this leads to a
change of the object, an update
(and possibly also a create
or delete
, see below) event will be triggered, unless silent
is set to true
.
-
getObject() - (object)
Returns the current root as a normal object.
-
setObjectForKeypath(< object >object, < string >rootKeypath, [< bool >silent]) - (void)
Sets all values of object
, where rootKeypath
will be the keypath to the
root of the object. If this leads to a change of the object, an update
(and possibly also a create
or delete
, see below) event will be
triggered, unless silent
is set to true
.
-
getObjectForKeypath(< string >keypath) - (object)
Returns the object from keypath
.
-
setValueForKeypath(< non-object >value, < string >keypath, [< bool >silent]) - (void)
Sets value
at keypath
. If this leads to a
change of the object, an update
(and possibly also a create
or delete
, see below) event will be triggered, unless silent
is set to true
.
-
getValueForKeypath(< string >keypath) - (non-object)
Returns the value at keypath
.
-
commit() - (void)
Commits uncommited changes made with silent
set to true
. This leads to
change events being emitted.