DEV Community


Discussion on: Things to watch out for when using HMR with Angular

anggachelsea profile image
Angga Lesmana

What do u think . If I use a subscribe in service?

dzhavat profile image
Dzhavat Ushev Author

There's no problem with that. Services have ngOnDestroy hook as well. You can use it for clean up.

layzee profile image
Lars Gyrup Brink Nielsen

That's good advice. Just don't try to use ngOnInit. It doesn't work for services. Instead, use the service constructor or an Angular initializer.