Last active
December 25, 2015 09:29
-
-
Save KazChe/6954708 to your computer and use it in GitHub Desktop.
simple Object.observe() - run in Chrome Canary with experimental javascript flag enabled.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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