【发布时间】:2013-08-01 17:49:56
【问题描述】:
setTimeout ->
console.log 'foo'
setTimeout ->
console.log 'bar'
setTimeout ->
console.log 'baz'
, 1000
, 1000
, 1000
是否可以使用 jQuery.Deferred 实现相同的结果?可能类似于以下内容:
someFunction()
.then(-> console.log 'foo')
.then(delay 1000)
.then(-> console.log 'bar')
.then(delay 1000)
.then(-> console.log 'baz')
也许我错误地认为 promise 让编写变得容易:做 A,完成后做 B,完成后做 C。
【问题讨论】:
-
类似的东西?:jsfiddle.net/gxFkn
-
确实!您想添加它作为答案吗?
标签: jquery coffeescript promise deferred