Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple states(Routes) when an event fire many times (multiple times) #62

Open
ankurkumarnodejs opened this issue May 18, 2018 · 3 comments

Comments

@ankurkumarnodejs
Copy link

I am connecting Angular2 application having multiple states(Routes) with Node server(Socket) running on the back-end. When I visit some other state and come back to the previous state where socket code is written in service file on the angular application created with fromEvent. the service called by subscribe() in multiple components which is called in ngoninit() { } . How often I move on routes gets a component view and event emit when an event fire, So many times (multiple times) the subscribed service gets called (multiple time show console.log("get message")), which affects the performance.

@ankurkumarnodejs
Copy link
Author

can anybody solve this problem?

@todorivanov
Copy link

Did you try to disconnect and unsubscribe from the socket on ngOnDestroy ?

@caboo2
Copy link

caboo2 commented Nov 14, 2018

try the removeListener() function when you destroy the page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants