Reputation: 605
I have an Angular2 app where user can log in and log out and I need to flush services data on log out, because they hold some data and backend subscriptions (websocket). Currently the only way I found is to reload the page after log out, but it's a crunchy solution. So, is there some convenient way to reinstantiate services (or remove the data they hold) in Angular2?
Upvotes: 1
Views: 138
Reputation: 6535
How about moving all your initialization logic to a method of that service, i.e init()
then call that from the constructor when the application starts or on user logout.
Upvotes: 1