我想让step.js库与coffee-script正常工作。我很新的咖啡,但这里是我的尝试:Step.js和CoffeeScript的异步控制流程
setTimeout(
=>
console.log("step 1 at #{new Date}")
setTimeout(
=>
console.log("step 2 at #{new Date}")
setTimeout(
=>
console.log("step 3 at #{new Date}")
10000
)
10000
)
10000
)
# step 1 at Tue Nov 13 2012 13:18:51 GMT-0600 (CST)
# step 2 at Tue Nov 13 2012 13:19:01 GMT-0600 (CST)
# step 3 at Tue Nov 13 2012 13:19:11 GMT-0600 (CST)
应该是一样的:
step(
->
setTimeout(
=>
console.log("step 1 at #{new Date}")
this(null)
10000
)
->
setTimeout(
=>
console.log("step 2 at #{new Date}")
this(null)
10000
)
->
setTimeout(
=>
console.log("step 3 at #{new Date}")
this(null)
10000
)
)
# step 1 at Tue Nov 13 2012 13:12:04 GMT-0600 (CST)
# step 2 at Tue Nov 13 2012 13:12:04 GMT-0600 (CST)
# step 3 at Tue Nov 13 2012 13:12:04 GMT-0600 (CST)
正如你可以从上面的例子步骤执行所有步骤在同一时间看到而不是像它应该那样一次一个地做它们。我不太清楚为什么这是现在。
谢谢你打我吧)。我喜欢你的回报没有未定义的价值,它更干净。我会将其标记为答案 –