Skip to content

Instantly share code, notes, and snippets.

@melanke
Forked from eligrey/object-watch.js
Created January 17, 2012 17:32
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save melanke/1627705 to your computer and use it in GitHub Desktop.
Save melanke/1627705 to your computer and use it in GitHub Desktop.
watch the changes of some object or attribute
@melanke
Copy link
Author

melanke commented Oct 18, 2012

@penartur it is explained in the paragraph "Chill out, no surprises, new attributes will not be considered"

@hellodaylight
Copy link

This is really useful. Thanks. One question: when watching more than one properties, is there a way to see what and how it was changed? i.e.:

o.watch(["x","y","z"], function (id, oldval, newval) {
console.log( "o." + id + " changed from " + oldval + " to " + newval );
});

@melanke
Copy link
Author

melanke commented Nov 10, 2012

With the new version of Watch.JS it is possible

Here is a sample:
http://jsfiddle.net/XnbXS/1/

Read the short-full-documentation:
https://github.com/melanke/Watch.JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment