Repository navigation
Replies: 1 comment
|
Keep the Subscription returned by const sub = new Subject();
const subscription = sub.subscribe({
next: handleValue,
error: handleError
});
// When this consumer is destroyed or no longer needs updates:
subscription.unsubscribe();A long-lived Subject retains its active subscriptions, including their callbacks. Calling Simply dropping your variable holding the subscription doesn't unsubscribe it. If the Subject stays reachable and never completes/errors, arrange cleanup in your component/service's teardown. The official Subscription guide explains this disposal model. Verified the unsubscribe and completion/error behavior with RxJS 7.8.2. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
const sub = new Subject();
sub.subscribe({
next:(r)=>{
...
},
error:(e)=>{
..
}
})
...
question is if need call unsubscribe() manually ??
I track my code that do subscribe handler, seem it was hold forever, I meaning seem not been free .
little confuse, or give some online official link on this type issue , thanks
All reactions