I have a service that returns a Subject<T>
and consumer is subscribing to it.
How would I cancel an existing subscription and dispose it?
Show activity on this post. When an Observable issues an OnError or OnComplete notification to its observers, this ends the subscription. Observers do not need to issue an Unsubscribe notification to end subscriptions that are ended by the Observable in this way.
When you call Subscribe() on your Subject<T>
, it returns an IDisposable
. Just call Dispose() on the returned handle, and it will cancel the subscription.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With