count
Counts the number of emissions on the source and emits that number when the source completes.
Parameters
Returns
OperatorFunction<T, number>
: An Observable of one number that represents the count as
described above.
Description
Tells how many values were emitted, when the source completes.
count
transforms an Observable that emits values into an Observable that
emits a single value that represents the number of values emitted by the
source Observable. If the source Observable terminates with an error, count
will pass this error notification along without emitting a value first. If
the source Observable does not terminate at all, count
will neither emit
a value nor terminate. This operator takes an optional predicate
function
as argument, in which case the output emission will represent the number of
source values that matched true
with the predicate
.
Examples
Counts how many seconds have passed before the first click happened
Counts how many odd numbers are there between 1 and 7