用链接包裹Rx JS Observable

时间:2017-05-23 12:25:59

标签: javascript rxjs rxjs5

有没有办法通过链接将Observerable映射到另一个?我现在正在这样做:

const myObserverable = fnThatReturnsObserverable();
return anotherFunctionThatReturnsObserverable(myObserverable);

有没有办法以链式方式做到这一点?

return fnThatReturnsObserverable().someOperator(anotherFunctionThatReturnsObserverable)

2 个答案:

答案 0 :(得分:2)

fnThatReturnsObserverable()
    .let(obs => anotherFunctionThatReturnsObserverable(obs));

有关它的更多信息here

答案 1 :(得分:-1)

您还可以使用ofmergeMap(or concatMap)

Observable.of(fnThatReturnsObserverable())
    .mergeMap(ob => anotherFunctionThatReturnsObserverable(obs));