Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Rx = require('rx');
- var e1 = new Rx.Subject();
- var e2 = new Rx.Subject();
- var e3 = new Rx.Subject();
- var e1s = e1.asObservable();
- var e2s = e2.asObservable();
- var e3s = e3.asObservable();
- e1s.
- flatMapLatest(function () {
- return e3s.
- startWith(true).
- flatMapLatest(function () {
- return e2s.delay(1000).takeUntil(e3s);
- })
- }).
- forEach(function (value) {
- console.log('value %s', value);
- });
- // NOT emit e2
- e1.onNext('e1');
- e2.onNext('e2');
- setTimeout(function () {
- // abort e2
- e3.onNext('e3');
- }, 500);
- setTimeout(function () {
- e1.onNext('e1');
- // should emit e2 since e3 is not happened
- e2.onNext('e2');
- }, 2000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement