-
Notifications
You must be signed in to change notification settings - Fork 8
richardszalay edited this page May 20, 2011
·
12 revisions
Returns the summed value of all the elements in the source sequence
function sum(): IObservable.<Number>
If there are no values in the source sequence, the sequence will emit 0.
The returned sequence completes when the source sequence completes.
The returned sequence raises an error if the source sequence raises an error.
xs = source
zs = output
xs ───o───o───o───o─/
2 + 4 + 6 + 8 │
│
zs ─────────────────o/
20
xs ───────────────/
│
│
zs ───────────────o/
0
IObservable.<Number>
Observable.range(1, 5)
.sum()
.subscribe(
function(value : int) : void { trace(value); },
function():void { trace("Completed"); }
);
// Trace output is:
// 15
// Completed
Observable.empty()
.sum()
.subscribe(
function(value : int) : void { trace(value); },
function():void { trace("Completed"); }
);
// Trace output is:
// 0
// Completed