combineLatest - 2
RxJS 5 combineLatest
HTML
<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.umd.js"></script>
JavaScript
//timerOne emits first value at 1s, then once every 4s
const timerOne = Rx.Observable.of(true);
//timerTwo emits first value at 2s, then once every 4s
const timerTwo = Rx.Observable.of(true)
//timerThree emits first value at 3s, then once every 4s
const timerThree = Rx.Observable.of(true)
//combineLatest also takes an optional projection function
const combinedProject = Rx.Observable
.combineLatest(
timerOne,
timerTwo,
timerThree,
(one, two, three) => one && two && three
);
//log values
const subscribe = combinedProject.subscribe(latestValuesProject => console.log(latestValuesProject));