我有多个observable,我想用concat observable链接。但我需要的是像compose一样的行为,b需要得到a和c的结果b。
function a(observable) { return observable.map()... }
function b(observable) { return observable.map()... }
function c(observable) { return observable.map()... }
const obs = Observable.of([...])
Observable.concat(a(obs), b(obs), c(obs)).subscribe(...)
我该怎么做?
答案 0 :(得分:1)
据我所知,Rx没有帮助编写功能。但是,这是你在寻找什么?
function a(source$) {
return source$.map(x => x + '-first')
}
function b(source$) {
return source$.map(x => x + '-second')
}
function c(source$) {
return source$.map(x => x + '-third')
}
const composed = R.compose(c, b, a);
composed(Rx.Observable.interval(1000))
.subscribe(val => {
console.log(val);
});

<script src="https://unpkg.com/@reactivex/rxjs@5.0.3/dist/global/Rx.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.min.js"></script>
&#13;