lastOrDefault - richardszalay/raix GitHub Wiki
ο»ΏEmits the last value from a source sequence or the default value if the source sequence is empty.
function lastOrDefault() : IObservable.<T>If the source sequence is empty, the default value for the sequence type will be emitted. The value will be 0 for numbers, false for Boolean, and null for all other values.
The returned sequence completes when the source sequence completes.
The returned sequence errors when the source sequences errors
xs = source
ys = output
xs ββoβββoβoββββoββ/
β
ββββ
β
ys ββββββββββββββββo/
xs ββββββββββββββββ/
β
β
β
ys ββββββββββββββββo
0/false/nullIObservable.<T>
var source : IObservable = Observable.empty()
.lastOrDefault();
source.subscribe(
function(value : int) : void { trace(value; },
function() : void { trace("Completed!"); }
);
// Trace output is:
// 0
// Completed!