【发布时间】:2015-04-18 21:32:01
【问题描述】:
我正在使用bluebird,如果这很重要的话。我有一个对象数组:
a = [obj1, obj2, obj3]
我想使用 Promise 对它们中的每一个进行迭代,然后进行一些处理。
a.each (obj) ->
doStuff obj
.then (objArray) ->
moreStuff()
我该怎么做?
更新
var addedFilesTree;
addedFilesTree = [1, 2, 3];
Promise.map(addedFilesTree).then(function(addedFileTree) {
return console.log(addedFileTree);
});
是我的实际代码。这会返回一个错误:
Possibly unhandled TypeError: fn must be a function
See http://goo.gl/916lJJ
【问题讨论】:
-
是的,这是 CoffeeScript
-
您的实际代码出错了,因为它缺少
doStuff函数。
标签: javascript arrays coffeescript promise bluebird