1
我需要一種方法來將值從observable傳遞給兩個函數,每個函數接受一個值,然後每個函數返回一個可觀察值(僅發射一個值,然後完成)。我希望.combineLatest()
可以讓我通過投影功能,但事實並非如此。RxJS5:.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
})
);
如何做到這一點任何想法?
那麼微不足道,一旦你讀它:) – Dyna
通常是RxJS但它需要一些時間來使用它:) – KwintenP