DefaultIfEmpty Operator

Rocket.default_if_emptyFunction
default_if_empty(value::T)

Creates a default_if_empty operator, which emits a given value if the source Observable completes without emitting any next value, otherwise mirrors the source Observable.

using Rocket

source = completed(Int) |> default_if_empty(0)

subscribe!(source, logger())
;

# output
[LogActor] Data: 0
[LogActor] Completed

See also: AbstractOperator, InferableOperator, logger, map

source

Description

default_if_empty emits the values emitted by the source Observable or a specified default value if the source Observable is empty (completes without having emitted any next value).

See also

Operators