Count Operator

Base.countFunction
count()

Creates a count operator, which counts the number of emissions on the source and emits that number when the source completes.

Producing

Stream of type <: Subscribable{Int}

Examples

using Rocket

source = from([ i for i in 1:42 ])
subscribe!(source |> count(), logger())
;

# output

[LogActor] Data: 42
[LogActor] Completed

See also: AbstractOperator, RightTypedOperator, ProxyObservable, logger

source

Description

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.

Example

Counts how many values source Observable have emitted before the complete event happened

using Rocket

source = from([ i for i in 1:42 ])
subscribe!(source |> count(), LoggerActor{Int}())

# output

[LogActor] Data: 42
[LogActor] Completed

See also

Operators