Skip to content

Instantly share code, notes, and snippets.

@magne4000
Created April 18, 2018 16:45
Show Gist options
  • Save magne4000/286adfbd3b57e58377637f4b7e53365a to your computer and use it in GitHub Desktop.
Save magne4000/286adfbd3b57e58377637f4b7e53365a to your computer and use it in GitHub Desktop.
RxJs combineLatest
const oa = Rx.Observable.from(['a0', 'a1', 'a2']);
const ob = Rx.Observable.from(['b0', 'b1', 'b2', 'b3']);
const oc = Rx.Observable.from(['c0', 'c1', 'c2', 'c3']);
const r1 = oa
.zip(Rx.Observable.interval(300), function(a, b) { return a; })
const r2 = ob
.zip(Rx.Observable.interval(440), function(a, b) { return a; })
const r3 = oc
.zip(Rx.Observable.interval(420), function(a, b) { return a; })
const listOfR = new Rx.Subject();
const u1 = Rx.Observable.combineLatest([r1]).subscribe(listOfR)
u1.unsubscribe()
const u2 = Rx.Observable.combineLatest([r1, r2]).subscribe(listOfR)
u2.unsubscribe()
Rx.Observable.combineLatest([r1, r2, r3]).subscribe(listOfR)
listOfR.do(console.log)
@magne4000
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment