Override Operator

Rocket.overrideFunction
override(handler::OverrideHandler)

Creates an override operator that overrides each emission from source observable with value provided in handler. If handler contains nothing source observable emits as usual. For constant override see map_to. Use Rocket.setvalue! to set new value for handler.

Producing

Stream of type <: Subscribable{Union{L, T}} where L refers to the type of source stream and T referes to the type of handler's value

Examples

using Rocket 

subject = Subject(Int)
handler = OverrideHandler(Int, -1)

source = subject |> override(handler)

subscription = subscribe!(source, logger())

next!(subject, 1)
next!(subject, 2)

Rocket.setvalue!(handler, nothing)

next!(subject, 3)
next!(subject, 4)

Rocket.setvalue!(handler, -2)

next!(subject, 5)
next!(subject, 6)

unsubscribe!(subscription)

# output
[LogActor] Data: -1
[LogActor] Data: -1
[LogActor] Data: 3
[LogActor] Data: 4
[LogActor] Data: -2
[LogActor] Data: -2

See also: OverrideHandler

source

See also

Operators