ngOnInit is not working when the server send event service used in multiple componenets

150 views Asked by At

I created a service for getting SSE(server send events) from backend(Node). When I use this service in one component it's working as expected. But when I try to use in multiple components at very first time ngoninit triggers and loads the data perfectly. When I navigate to one component to another the ngoninit is not triggering and even the services are also not being called. I hope someone can help on this.

Thanks in advance.

1

There are 1 answers

1
Bertramp On

Sounds like your components are not removed from the view and therefore not destroyed. Then ngOnInit will not trigger, because an instance of the component already exists