Skip to content

Instantly share code, notes, and snippets.

@weepy
Created April 24, 2013 16:01
Show Gist options
  • Select an option

  • Save weepy/5453276 to your computer and use it in GitHub Desktop.

Select an option

Save weepy/5453276 to your computer and use it in GitHub Desktop.
simple observer
function watch(o, prop, fn) {
var interval = 100
var value = o[prop]
function check() {
if(o[prop] != value) {
fn(o[prop], value)
value = o[prop]
}
setTimeout(check, interval)
}
check()
return function(o) {
interval = o.interval
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment