-
Notifications
You must be signed in to change notification settings - Fork 8
count
richardszalay edited this page May 20, 2011
·
7 revisions
Returns the number of elements in the source sequence
static function count() : IObservable.<int>
When the sequence completes, returns the number of values in the sequence.
The returned sequence completes when the source sequence completes.
The returned sequence raises an error if the source sequence raises an error.
xs = source
ys = output
xs ───o───o──o──o─/
│
│
ys ───────────────o/
4
xs ───────────────/
│
│
ys ───────────────o/
0
`
h3. Return Value
@IObservable.<uint>@
h2. Examples
```as3
Observable.range(10, 5)
.count()
.subscribe(
function(value : int) : void { trace(value); },
function():void { trace("Completed"); }
);
// Trace output is:
// 5
// Completed
// Counts the number of even numbers between 1 and 50 (inclusive)
Observable.range(1, 50)
.filter(function(x:int):Boolean { return (x % 2) == 0; })
.count()
.subscribe(
function(value : int) : void { trace(value); },
function():void { trace("Completed"); }
);
// Trace output is:
// 25
// Completed