Can you tell when share() completes/unsubscribes? #6253
Answered
by
cartant
raymonddavis
asked this question in
Q&A
-
The share() pipe completes when the last subscriber unsubscribes. Is there a way to be notified or run a function when the share unsubscribes? |
Beta Was this translation helpful? Give feedback.
Answered by
cartant
Apr 23, 2021
Replies: 1 comment
-
You can use the const shared = source.pipe(
finalize(() => { /* whatever */ }),
share()
); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
raymonddavis
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the
finalize
operator to run a function when the source completes, errors or is explicitly unsubscribed: