-
-
Save ColinCampbell/517491 to your computer and use it in GitHub Desktop.
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
addFiniteObserver: function(key, target, method, context){ | |
// normalize. if a function is passed to target, make it the method. | |
if (method === undefined) { | |
method = target; target = this ; | |
} | |
if (!target) target = this ; | |
if (typeof method === "string") method = target[method] ; | |
if (!method) throw "You must pass a method to addObserver()" ; | |
var me = this; // replace by context? | |
var f = function() { | |
var val = me.get(key); | |
var ret = method.call(target, me, key, null); | |
console.log("addFiniteObserver function called: val = " + val + " and ret = " + ret); | |
if(ret){ | |
me.removeObserver(key, me, f); | |
} | |
}; | |
this.addObserver(key, target, f); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment