Recursive object Observer
Switch branches/tags
Nothing to show
Clone or download
Latest commit 6f6a86e Sep 7, 2015
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib module export added Sep 7, 2015
src module export added Sep 7, 2015
test try chrome to fix travis tests Feb 27, 2015
.gitignore Initial commit Oct 29, 2014
.travis.yml Create .travis.yml Feb 27, 2015
LICENSE Initial commit Oct 29, 2014 Update Sep 7, 2015
package.json PhantomJS, needs the Array.Oberve and Object.Observe to work Feb 27, 2015


Recursive Object Observer

This helps and reports back for any changes that may happen to an object, reports back the path and the value it has changed into.

This is a coffee script atm (as it's only first draft)

#testing The tests are failing because Object.observe is not defined in phantom when tests run.

If you know how to run tests you can change the PhantomJS to Chrome on the package manager under scripts.test to test it locally. then you can run it with npm test on you CLI

npm test

#how it works

parson = {name: "Tom", age: 18}

new Observe( person , function (changes, original){
} ) = "Ben";   // {value: "Ben", path: name}
person.age = 20;   // {value: 20, path: 'age'}

This should also work for recursive, and future ancestors which are added into the object.

person.children = [{name:"Joe"} , {name: "Kim"} , {name:"Tom"} ]
person.children[1].name = 'ana'; //{value: "ana", path: 'children[1].name'}

This object is especially useful when binding (one way or two-way) to listen for changes taking advantage of the native Object.observe(obj, callback) aka O.o in a recursive mode, therefore performance should be optimal.

Raise a ticket if you would like to contribute.

#What is the original parameter?

This is the default changes, which the native Object.observe uses, if you would rather use the native so be it :), this has a more details information of what has happened to a particular object, however it may be tricky when working with deep objects.