diTii.com Digital News Hub

Sign up with your email address to be the first to know about latest news and more.

I agree to have my personal information transfered to MailChimp (more information)

Sep042006

Dojo Deferred and DFS

Brian McCallister has written about Dojo Deferred and DFS —”A while back I talked about the “DataFlowSequence” which Tim and I came up with for dealing with concurrent XHRs. In the interim Dojo created a Deferred class based on MochiKit‘s Deferred class, which in turn is based on Twisted‘s Deferred. Using Dojo’s goes like this:


var d = new dojo.Deferred();

// register callback

d.addCallback(function(name) {
log.debug("name: " + name)
});

// supply data
d.callback("Sam Jones");

Deferred has an additional registerable callback, an errback, which is called if Deferred#errback(value) is invoked instead of Deferred#callback(value).


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!")
}

For more info…

ajaxian

Dojo Deferred and DFS, Dojo

Share This Story, Choose Your Platform!

Get Latest News

Subscribe to Digital News Hub

Get our daily newsletter about the latest news in the industry.
First Name
Last Name
Email address
Secure and Spam free...