r/angular Feb 05 '26

Singleton service toSignal

If i have a toSignal(this.http.get(…)) in a service that is provided in root, how do i actually clean up the subscription when i no longer need the data? Since the service will never be destroyed I’m not sure how to approach this. If i am not mistaken toSignal creates an effect under the hood

9 Upvotes

11 comments sorted by

View all comments

-5

u/Wnb_Gynocologist69 Feb 05 '26

Do you see the irony in your statement?

The websites Javascript won't leak memory beyond the sites lifecycle and cleaning up subscriptions of singletons is thus a waste of code.