Skip to content

capaj/observe-deep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

observe-deep

A function for robust observing of the whole object tree, not just own properties on the observed object. Uses ES6 Object.observe. Works anywhere where Object.observe is and WeakMap is.

Install

Just run: npm install observe-deep or jspm install npm:observe-deep

Usage

Api is modelled similarly to Object.observe, so:

var observed = {a: {b: 1}, c:2};
function observer(changesTriggered) {
    console.log(changesTriggered);
}
var deliver = observeDeep(observed, observer);
//deliver can be used for synchronous delivery of changes on demand

Utility

Why? Because we can! Also I believe this little observation helper can save you a lot of troubles when you use MVVM pattern for your app. Observing, you can be sure your views are rendered whenever anything changes in your model. So could this be used instead of Flux for example? Or instead of dirty checking for Angular 1.x.x? I believe it could, I will try to prove that claim soon.

TODO

Try using observe-js, so that we can support other browsers as well.

About

observeDeep function for simple observing of the whole object tree, not just the keys and values

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published