RxPHP implements this operator as switch
.
Transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
Sample Code//from https://github.com/ReactiveX/RxPHP/blob/master/demo/switch/switch.php $source = Rx\Observable::range(0, 3) ->map(function ($x) { return \Rx\Observable::range($x, 3); }) ->switch(); $subscription = $source->subscribe($stdoutObserver);
Next value: 0 Next value: 1 Next value: 2 Next value: 3 Next value: 4 Complete!
RxPHP also has an operator switchFirst
.
Receives an Observable of Observables and propagates the first Observable exclusively until it completes before it begins subscribes to the next Observable. Observables that come before the current Observable completes will be dropped and will not propagate. This operator is similar to concatAll() except that it will not hold onto Observables that come in before the current one is finished completed.
Sample Code//from https://github.com/ReactiveX/RxPHP/blob/master/demo/switch/switchFirst.php $source = Rx\Observable::fromArray([ \Rx\Observable::interval(100)->mapTo('a'), \Rx\Observable::interval(200)->mapTo('b'), \Rx\Observable::interval(300)->mapTo('c'), ]) ->switchFirst() ->take(3); $subscription = $source->subscribe($stdoutObserver);
Next value: a Next value: a Next value: a Complete!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4