Skip to content

Instantly share code, notes, and snippets.

@KazChe
Last active December 25, 2015 09:29
Show Gist options
  • Save KazChe/6954708 to your computer and use it in GitHub Desktop.
Save KazChe/6954708 to your computer and use it in GitHub Desktop.
simple Object.observe() - run in Chrome Canary with experimental javascript flag enabled.
function ObserveMe() {
var x =
{
"thing":
{ "label": "party",
"value": "republican"
}
}
return x;
}
function observer(changes) {
console.log('changes: ' + JSON.stringify(changes));
}
------------------- in chrome dev tools console -----------------------
var x = ObserveMe();
Object.observe(x, observer);
Object {thing: Object}
x.a = "new thing";
changes: [{"type":"new","object":{"thing":{"label":"party","value":"republican"},"a":"new thing"},"name":"a"}]
"new thing"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment