onErrorResumeNext - richardszalay/raix GitHub Wiki
ο»ΏSubscribes to a second sequence when the source sequence completes or errors
function onErrorResumeNext(second : IObservable.<T>) : IObservable.<T>Where second must have the same valueClass as the source sequence
Given an array of sequences, subscribes to each after the previous one completes or errors.
static function onErrorResumeNext(
sources : Array.< IObservable.<T> >) : IObservable.<T>
Where sources must all have the same valueClass
Acts as a hybrid of concat and catchError / catchErrors, in that subsequent sequences are subscribed to whether the previous sequence completes or errors.
The returned sequence completes if second completes
The returned sequence errors if second errors.
(static) The returned sequence completes if the last sequence in sources completes
(static) The returned sequence errors if the last sequence in sources errors.
ws,xs,ys = sources
zs = output
ws ββoβββββoβββββ/
β β β
xs β β ββoβoβx
β β β β β
ys β β β β ββoβoβ/
β β β β β β β
zs ββoβββββoβββββββoβoβββoβoβ/
ws ββoβββββoβββββx
β β β
xs β β ββoβoβx
β β β β β
ys β β β β ββoβoβx
β β β β β β β
zs ββoβββββoβββββββoβoβββoβoβx
ws ββoβββββoβββββx
β β β
xs β β ββoβoβx
β β β β β
ys β β β β ββoβoβ/
β β β β β β β
zs ββoβββββoβββββββoβoβββoβoβ/Unless specified, Scheduler.synchronous will be used to schedule the subscription to each source, including the first.
IObservable.<T>
var sourceA : IObservable = Observable.value(1)
.onErrorResumeNext(Observable.value(2))
.subscribe(
function(x:int) : void { trace(x); },
function() : void { trace("Completed"); },
function(e:Error) : void { trace("Error: " + e.message); }
);
// Trace output is:
// 1
// 2
// Completedvar sourceA : IObservable = Observable.value(1);
var sourceB : IObservable = Observable.value(2)
.concat(int, Observable.error(new Error("Error 2"));
var sourceC : IObservable = Observable.value(3);
Observable.onErrorResumeNext([sourceA, sourceB, sourceC])
.subscribe(
function(x:int) : void { trace(x); },
function() : void { trace("Completed"); },
function(e:Error) : void { trace("Error: " + e.message); }
);
// Trace output is:
// 1
// 2
// 3
// Completedvar sourceA : IObservable = Observable.value(1)
.concat(int, Observable.error(new Error("Error 1"));
var sourceB : IObservable = Observable.value(2);
var sourceC : IObservable = Observable.value(3)
.concat(int, Observable.error(new Error("Error 3"));
Observable.onErrorResumeNext([sourceA, sourceB, sourceC])
.subscribe(
function(x:int) : void { trace(x); },
function() : void { trace("Completed"); },
function(e:Error) : void { trace("Error: " + e.message); }
);
// Trace output is:
// 1
// 2
// 3
// Error: Error 3