TapOnSubscribe Operator
Rocket.TapBeforeSubscription — TypeTapBeforeSubscriptionOne of the strategies for tap_on_subscribe operator. With TapBeforeSubscription tap callback will be called before actual subscription.
See also: tap_on_subscribe, TapAfterSubscription
Rocket.TapAfterSubscription — TypeTapAfterSubscriptionOne of the strategies for tap_on_subscribe operator. With TapBeforeSubscription tap callback will be called after actual subscription.
See also: tap_on_subscribe, TapBeforeSubscription
Rocket.tap_on_subscribe — Functiontap_on_subscribe(tapFn::F, strategy::S = TapBeforeSubscription()) where { F <: Function }Creates a tap operator, which performs a side effect on the subscription on the source Observable, but return an Observable that is identical to the source.
Arguments
tapFn::Function: side-effect tap function with() -> Nothingsignaturestrategy: (optional), specifies the order of a side-effect and an actual subscription, usesTapBeforeSubscriptionby default
Producing
Stream of type <: Subscribable{L} where L refers to type of source stream
Examples
using Rocket
source = from([ 1, 2, 3 ])
subscribe!(source |> tap_on_subscribe(() -> println("Someone subscribed")), logger())
;
# output
Someone subscribed
[LogActor] Data: 1
[LogActor] Data: 2
[LogActor] Data: 3
[LogActor] Completedusing Rocket
source = from([ 1, 2, 3 ])
subscribe!(source |> tap_on_subscribe(() -> println("Someone subscribed"), TapAfterSubscription()), logger())
;
# output
[LogActor] Data: 1
[LogActor] Data: 2
[LogActor] Data: 3
[LogActor] Completed
Someone subscribedSee also: TapBeforeSubscription, TapAfterSubscription, tap, tap_on_unsubscribe, 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 subscription to the source.
This operator is useful for debugging your Observables, verifying correctness, or performing other side effects.
Note: this operator differs from a subscribe on the Observable. If the Observable returned by tap_on_subscribe is not subscribed, the side effects specified by the Observer will never happen. tap_on_subscribe therefore simply spies on future execution, it does not trigger an execution to happen like subscribe does.