Operator: onSubscribe
, subscriptionTap
to trigger callback at time of subscription
#7436
Closed
aYorky
started this conversation in
Ideas / Feature request
Replies: 1 comment 1 reply
-
Perhaps tap({
subscribe: () => console.log('subscribe'),
unsubscribe: () => console.log('unsubscribe'),
finalize: () => console.log('finalize')
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I recently ran into a scenario where it would have been extremely helpful to know/trigger some side effect when a subscription happens. I looked at
startWith
, but that emits a value, which is not what I was looking for. I needed something liketap
that doesn't wait for values to be emitted. I realized that Observables fundamentally do not have a way to indicate when they've been subscribed (right? I wouldn't say I'm an expert. 🙂), and there was only one question on SO that I could find with a similar scenario, and I wasn't impressed with the answer. Eventually I created the following custom operator, and I think it could be useful to others as well. I'm not beholden to the name.Beta Was this translation helpful? Give feedback.
All reactions