TapOnUnsubscribe Operator

Rocket.tap_on_unsubscribeFunction
tap_on_unsubscribe(tapFn::F, strategy::S = TapBeforeUnsubscription()) where { F <: Function }

Creates a tap operator, which performs a side effect on the unsubscription on the source Observable, but return an Observable that is identical to the source. Tap callback triggers only once.

Arguments

  • tapFn::Function: side-effect tap function with () -> Nothing signature
  • strategy: (optional), specifies the order of a side-effect and an actual unsubscription, uses TapBeforeUnsubscription by default

Producing

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

Examples

using Rocket

source = from([ 1, 2, 3 ])
subscription = subscribe!(source |> tap_on_unsubscribe(() -> println("Someone unsubscribed")), logger())
unsubscribe!(subscription)
;

# output

[LogActor] Data: 1
[LogActor] Data: 2
[LogActor] Data: 3
[LogActor] Completed
Someone unsubscribed

See also: TapBeforeUnsubscription, TapAfterUnsubscription, tap, tap_on_subscribe, tap_on_complete, logger

source

Description

Returns an Observable that resembles the source Observable, but modifies it so that the provided Observer is called to perform a side effect on unsubscription from the source.

This operator is useful for debugging your Observables, verifying correctness, or performing other side effects.

See also

Operators