【发布时间】:2014-06-04 19:32:21
【问题描述】:
我正在使用Promises 构建一个模块,在其中我对多个网址进行多次http调用,解析响应,然后再次进行更多http调用。
c = new RSVP.Promise({urls:[]}) //Passing a list of urls
c.then(http_module1) // Call the http module
.then(parsing_module) // Parsing the responses and extract the hyperlinks
.then(http_module2) // Making http requests on the data produced by the parser before.
.then(print_module) // Prints out the responses.
问题是——如果我使用一个promise,我不能解析模块,除非所有的http请求都完成了。这是因为 - Once a promise has been resolved or rejected, it cannot be resolved or rejected again.
构建我自己的 Promise 版本还是有其他方法?
【问题讨论】:
-
问题不是很清楚。
标签: javascript promise rsvp-promise