【发布时间】:2011-03-29 13:26:57
【问题描述】:
我有一个异步调用链,使用 dojo.Deferred 对象作为异步包装器链接在一起(至少我是这么理解的)和 .then() 函数来“链接”异步调用。
在链中的任何一个链接中,某些测试可能会失败(例如我的异步存储提取未返回任何对象等),我想优雅地退出整个 .then() 链。
这是我使用的链的形式。我如何杀死我指出的整个链条?
asyncFunc(...).then( function(args) {
//stuff...
return myDeferredReturningFunction(args);
}).then( function(args2) {
//do some test on args2
//if test fails, **how to cancel the chain here?**
}).then( function(args3) { ... etc etc ...
注意:也许有人可以将其标记为“dojo.Deferred”?
【问题讨论】:
标签: asynchronous dojo