observejs
Watch a Javascript object for changes and stream changes to another object using node.js Streams.
Installation
Install with npm:
$ npm install observejs
Example
var observejs = ;// the source objectvar o =name: 'Eugene'number: 42tags: 'tag1' 'tag2' 'tag3'cars:make: 'Toyota'model: 'Camry'make: 'Toyota'model: 'Corolla';// deep clone of ovar o2 = JSON;// Replicate any changes to o2observejs;// Make some changes to the source objectoname = 'Susan';onumber = 43;onumber = undefined;ocars0make = 'Holden';ocars;// o and o2 should be equaltodeep;
methods
var observejs = ;
observejs.observe(src)
Watch the object src
for any changes. Returns a stream which can be used
with observerjs.changes(dest)
to keep another object in sync.
observejs.unobserve(src)
Stop watching the object src
.
observejs.changes(dest)
Stream which takes the data from an observerjs.observer(src)
and keeps
the target object dest
in sync with the source.