Skip to content

Instantly share code, notes, and snippets.

@novemberborn
Created July 28, 2010 12:43
Show Gist options
  • Save novemberborn/494358 to your computer and use it in GitHub Desktop.
Save novemberborn/494358 to your computer and use it in GitHub Desktop.
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