Last Operator
Base.last — Functionlast(; default = nothing)Creates a last operator, which returns an Observable that emits only the last item emitted by the source Observable. Sends LastNotFoundException error message if a given source completes without emitting a single value.
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() |> catch_error((err, obs) -> of(1)), logger())
;
# output
[LogActor] Data: 1
[LogActor] Completedusing Rocket
source = from(Int[])
subscribe!(source |> last(default = 1), logger())
;
# output
[LogActor] Data: 1
[LogActor] CompletedSee also: AbstractOperator, InferableOperator, ProxyObservable, logger
Description
last operator returns an Observable that emits only the last item emitted by the source Observable.