Take Operator

Rocket.takeFunction
take(maxcount::Int)

Creates a take operator, which returns an Observable that emits only the first maxcount values emitted by the source Observable.

Arguments

  • maxcount::Int: the maximum number of next values to emit.

Producing

Stream of type <: Subscribable{L} where L refers to type of source stream

Examples

using Rocket

source = from([ i for i in 1:100 ])

subscribe!(source |> take(5), logger())
;

# output

[LogActor] Data: 1
[LogActor] Data: 2
[LogActor] Data: 3
[LogActor] Data: 4
[LogActor] Data: 5
[LogActor] Completed

See also: AbstractOperator, InferableOperator, ProxyObservable, logger

source

Description

take returns an Observable that emits only the first count values emitted by the source Observable. If the source emits fewer than count values, then all of its values are emitted. Afterwards, the Observable completes regardless of whether the source completed.

See also

Operators