【发布时间】:2016-12-04 09:47:19
【问题描述】:
我需要访问流的“原始”值。
我的用例:
- 迭代 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).
});
有什么想法吗? :)
【问题讨论】:
标签: javascript functional-programming rxjs rxjs5