TapOnUnsubscribe Operator
Rocket.TapBeforeUnsubscription — TypeTapBeforeUnsubscriptionOne of the strategies for tap_on_unsubscribe operator. With TapBeforeUnubscription tap callback will be called before actual unsubscription.
See also: tap_on_unsubscribe, TapAfterUnsubscription
Rocket.TapAfterUnsubscription — TypeTapAfterUnsubscriptionOne of the strategies for tap_on_unsubscribe operator. With TapBeforeUnsubscription tap callback will be called after actual unsubscription.
See also: tap_on_unsubscribe, TapBeforeUnsubscription
Rocket.tap_on_unsubscribe — Functiontap_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() -> Nothingsignaturestrategy: (optional), specifies the order of a side-effect and an actual unsubscription, usesTapBeforeUnsubscriptionby 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 unsubscribedSee also: TapBeforeUnsubscription, TapAfterUnsubscription, tap, tap_on_subscribe, tap_on_complete, logger
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.