Skip to content

Instantly share code, notes, and snippets.

@matygo
Created September 17, 2010 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matygo/585048 to your computer and use it in GitHub Desktop.
Save matygo/585048 to your computer and use it in GitHub Desktop.
// The api (see http://github.com/sproutit/sproutcore/blob/quilmes/frameworks/runtime/mixins/observable.js#L616-664 )
// seems to imply this should work. For me it doesn't, "context" is not being passed to the callback
// This 'test' should run in any sproutcore context loaded console - just copy paste
var contextToPass = {"key": "My Key", "blah": "pablo"};
var fooObj = SC.Object.create({"foo": "Hi"});
var barObj = SC.Object.create({
fooDidChange: function(sender, key, value, context, rev){
console.log(sender);
console.log(key);
console.log(value);
console.log(context);
console.log(rev);
console.log("Test context key: " + context["key"] === "My Key");
console.log("Test context blah: " + context["blah"] === "pablo");
}
});
fooObj.addObserver("foo", barObj, "fooDidChange", contextToPass);
fooObj.set("foo", "Work Please!");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment