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。