Hi, we have an interesting issue where we have a number of providers with spread use around the application where each also has some data stored (mostly an array of objects they handle). Now the problem we are facing is how do we “reset” these injectable services when the user logs out? We want to do a complete flush, preferably so that the next login attempt the modules are recreated since we also do some initialization in the constructors of them (starting sync of data to server).
At the moment the only way I can see us handling this manually is to inject all our services in the “homepage” that the user goes to after logging in. And then from there explicitly also call some destroy/reset method in our service when e.g. the homepage is unloaded. It also means we have to manually call some init method in each service as well after the user has logged in. Atm these were instantiated and initialized as needed when they were first injected (some services are actually not needed until you reach that particular page).
Would love to get some best practices and best ways to solve this from other coders here!