【发布时间】:2013-05-21 12:13:39
【问题描述】:
用
在 Javascript (node.js) 中构建流畅界面的最佳方法是什么obj.function1().function2().function3();
哪里的函数是异步方法?
有一个名为chainsaw的模块,但如果它可能与deferreds和promise有关(https://github.com/kriskowal/q)
UPD:使用 q.js 链接
obj.function1().then(obj.function2)
//inside obj.function2 "this" context is lost,
//and code is actually broken
obj.function1().then(funciton(){
obj.function2() // <-- "this" context is OK
})
【问题讨论】:
标签: javascript node.js fluent-interface deferred