-
Notifications
You must be signed in to change notification settings - Fork 8
finallyAction
richardszalay edited this page May 20, 2011
·
7 revisions
Executes a function when the sequence completes or errors.
function finallyAction(action : Function) : IObservable.<T>
Where action is function () : void
The returned sequence completes if the source sequence completes
The returned sequence errors if the source sequence errors or if finallyAction throws an error
f() = finallyAction
xs ──o─────o─────/
├f()
zs ──o─────o─────/
xs ──o─────o─────x
├f()
zs ──o─────o─────x
IObservable.<T>
Observable.value(1)
.finallyAction(
function():void { trace("Finally!"); }
)
.subscribe(
function(x:int) : void { trace(x); },
function() : void { trace("Completed"); },
function(e:Error) : void { trace("Error: " + e.message); }
);
// Trace output is:
// 1
// Finally!
// Completed
Observable.error(new Error("Boo!"))
.finallyAction(
function():void { trace("Finally!"); }
)
.subscribe(
function(x:int) : void { trace(x); },
function() : void { trace("Completed"); },
function(e:Error) : void { trace("Error: " + e.message); }
);
// Trace output is:
// Finally!
// Error: Boo!