In the below example, foo
receives data from bar
yet ignores when bar
completes. foo
is completed when baz
completes, which is not the behavior I desire.
var baz = Rx.Observable.interval( 50 ).take( 10 );
var foo = baz
.select(function (x) {
var bar = Rx.Observable.range(x, 3);
return bar;
})
.switch();
Is there a variant of switch
or a technique that I could use to have the newly created foo
observable have the same lifetime as bar
? That is, I would like foo
to complete in the event that bar
completes.
Solution:
var baz = Rx.Observable.interval( 50 ).take( 10 );
var foo = baz
.select(function (x) {
var bar = Rx.Observable.range(x, 3).materialize()
return bar;
})
.switch()
.dematerialize();