In my main global module, I have an app store.
However, there is a separate lazy-loaded module called the "users" module (accessible through the route /users) that contains a featured store.
- When I first access the homepage of the application (app module), the app store is loaded.
- Upon navigating to the /users route, the users module is loaded along with the users store.
- At this point, my store includes both the app store and the users store.
- If I navigate away from the users section, I want to remove the users store from the state.
I attempted to reset the user state in the ngOnDestroy method of my principal users component in order to remove it, but the action did not trigger.
ngOnDestroy() {
this.store.dispatch(fromFeature.resetStoreAction());
}
This is necessary because the modules are accessible based on roles, and having the "users-store" in memory when it's not needed is inefficient.