【发布时间】:2017-03-31 19:33:22
【问题描述】:
我需要一种方法将值从一个 observable 传递到两个函数,每个函数都接受一个值,每个函数又返回一个 observable(只发出一个值,然后完成)。我希望.combineLatest() 可以让我通过投影函数,但它没有。
示例代码(不工作):
const ac = [1, 2, 3]; // only as example, I have complex types in my array not numbers
Observable.from(ac)
.combineLatest(
// processFn should get a number as argument and return Observable<number>
// does not work because .combineLatest does not accept two functions as arguments :(
n => processFn1(n),
n => processFn2(n)
)
.map(([result1, result2] => {
// result1, result2 should be flat numbers here, not Observables
})
);
你知道怎么做吗?
【问题讨论】:
标签: javascript typescript rxjs rxjs5 reactivex