Monday, September 4th, 2006
Dojo’s Deferred API
<>p>Brian McCallister has written more about Dojo Deferred and DFS in which he talks about the new Dojo Deferred class based on MochiKits and Twisteds.-
-
var d = new dojo.Deferred();
-
-
// register callback
-
-
d.addCallback(function(name) {
-
log.debug("name: " + name)
-
});
-
-
-
// supply data
-
d.callback("Sam Jones");
-
or with errors:
-
-
var d = new dojo.Deferred();
-
d.addCallback(function(v) { log.debug("success! : " + v) })
-
d.addErrback(function(e) { log.debug("error! : " + v) })
-
-
-
if (Math.random()> 0.5) {
-
d.callback("yea!")
-
}
-
else {
-
d.errback("boo!")
-
}
-
Related Content:











To give credit where it’s due, Dojo’s Deferred API is a direct port from MochiKit’s excellent implementation. All credit for this goes to Bob, and errors in the implementation are quite certainly ours.
Regards
I’m not the smartest JS-kid in town, but shouldn’t that read:
d.addErrback(function(e) { log.debug(“error! : ” + e) })?