Created
July 28, 2010 12:43
-
-
Save novemberborn/494358 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
var Observer = dojo.extend(function(){}, { | |
observe: function(promise){ | |
this.onStart(promise); | |
promise.then(dojo.hitch(this, "onEnd")); | |
return promise; | |
}, | |
onStart: function(promise){}, | |
onEnd: function(result){} | |
}); | |
var observer = new Observer; | |
dojo.connect(observer, "onStart", function(promise){ | |
console.log("Started with promise", promise); | |
}); | |
dojo.connect(observer, "onEnd", function(result){ | |
console.log("Got result", result); | |
}); | |
var dfd = new dojo.Deferred; | |
observer.observe(dfd.promise); | |
dfd.resolve("Done"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment