2
我需要访问流的“原始”值。在RxJs中跟踪“原始”项目
我用例:URL的
- 迭代列表。
- 请求每个URL。
- 处理响应,此时,我还需要第一个“迭代”中的URL。
示例代码:
const Rx = require('rxjs');
const request = require('request');
// my request method in Rx version
const req = Rx.Observable.bindNodeCallback(request);
const list = [/*list of URLs*/];
Rx.Observable.from(list)
.flatMap(req) // eq to: .flatMap(url => req(url))
.map(response => {
// here I need the response object
// and the URL I used to request it (the "original" value).
});
任何想法? :)
你是生命的救星:)谢谢! – Ziv