-
Notifications
You must be signed in to change notification settings - Fork 0
onErrorResumeNext
Subscribes to a second sequence when he source sequence completes or errors
function onErrorResumeNext(second : IObservable) : IObservable.<sourceValueClass>
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>) : IObservable.<sourcesValueClass>
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.<valueClass>
var sourceA : IObservable = Observable.returnValue(1)
.onErrorResumeNext(Observable.returnValue(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
// Completed
var sourceA : IObservable = Observable.returnValue(1);
var sourceB : IObservable = Observable.returnValue(2)
.concat(int, Observable.throwError(new Error("Error 2"));
var sourceC : IObservable = Observable.returnValue(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
// Completed
var sourceA : IObservable = Observable.returnValue(1)
.concat(int, Observable.throwError(new Error("Error 1"));
var sourceB : IObservable = Observable.returnValue(2);
var sourceC : IObservable = Observable.returnValue(3)
.concat(int, Observable.throwError(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