Does deleting an observable also delete subscriptions on it?

Craig

I have an Angular form array of groups. Elsewhere in the app some subscriptions are setup on formcontrol validation changes. At some point in the life cycle I delete a formgroup. Do I need to be concerned that subscriptions are still open on objects that arent in memory anymore?

Per Hornshøj-Schierbeck

NO

If you call .subscribe anywhere in your code, the only way to not leak memory is to make sure those subscriptions gets unsubscribed again.

You need to either manually unsubscribe each one or make sure the observables you subscribe to are all finite - meaning they have an "end" signal somewhere. They can be either a limited sequence (.first(), .take(), etc) or they can be toggled off by ending in a .takeWhile() or .takeUntil()

The subscriptions does not care if you leave scope, remove referenced object or even navigate away. You need to make sure they get unsubscribed.

See my answer here: RXJS - Angular - unsubscribe from Subjects

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Does deleting an AutoML Vision dataset also delete the model?

Does deleting a file from my computer also delete it from Ubuntu One?

Does deleting a person in Chrome delete it in all computers?

Does deleting venv delete installed modules?

Deleting a file from storage does not delete an image

Deleting a resource in Azure - Does it delete Alerts associated with it

Multiple subscriptions to Observable

Working around with observable and subscriptions

Does deleting the copy constructor also deletes default copy/move operators?

Does clearing cookies in firefox also delete localStorage?

Knockout single observable with multiple subscriptions

RxSwift multiple subscriptions to one observable

Managing Observable Subscriptions with Synchronous Streams

When deleting a CoreData Object, how to also delete all of its related Objects in Swift5?

Google Calendar API: Deleting a Event does not delete an Event Id

Deleting all items of a ttk.Treeview does not delete or unconfigure their tagNames?

SQLALCHEMY deleting Association Object does not delete it from the parent and child

Does deleting a collection in the firebase/firestore console delete all sub collections?

Does ArrayList.clear() also delete all contained objecs?

Delete MQ Series subscriptions on Windows

Cannot delete Instagram realtime subscriptions

Does deleting the rows from table also release space of large objects in CLOB or BLOB columns?

Angular 2 - Handling multiple subscriptions on a single observable

Best way to chain observable subscriptions in Angular?

Knockout observable subscriptions: maximum call stack exceeded

Replace Middleware Pattern with Observable (subscriptions cancel?)

Delete method in Angular is not deleting

Delete Query Not Deleting

Delete Method Not Deleting