Last Operator

Base.lastFunction
last(; default = nothing)

Creates a last operator, which returns an Observable that emits only the last item emitted by the source Observable.

Arguments

  • default: an optional default value to provide if no values were emitted

Producing

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

Examples

using Rocket

source = from([ 1, 2, 3 ])
subscribe!(source |> last(), logger())
;

# output

[LogActor] Data: 3
[LogActor] Completed
using Rocket

source = from(Int[])
subscribe!(source |> last(), logger())
;

# output

[LogActor] Completed
using Rocket

source = from(Int[])
subscribe!(source |> last(default = 1), logger())
;

# output

[LogActor] Data: 1
[LogActor] Completed

See also: AbstractOperator, InferableOperator, ProxyObservable, logger

source

Description

last operator returns an Observable that emits only the last item emitted by the source Observable.

See also

Operators