Closed Andreas-Hjortland closed 1 month ago
This will be resolved in the next release of NGXS. We will comment here when the release goes out.
That’s awesome. Thank you so much for the work that you do =)
You can use the dev version before the release goes out @ngxs/store@18.1.1-dev.master-a8f62df
.
Affected Package
The issue is caused by package @ngxs/store
Is this a regression?
No, although I have a project that works with
@NgModule
.Description
If I add a plugin that i lazily load through the router, the plugin will not be invoked when we dispatch an action.
🔬 Minimal Reproduction
https://stackblitz.com/~/github.com/Andreas-Hjortland/ngxs-standalone-plugin-repro
We add the plugin in
src/app/foo/routes.ts
along with the state for that component, but the plugin is never invoked.If you remove the comment for the
ENVIRONMENT_INITIALIZER
, it works. This hack just iterates over all the services registered in the dependency scope and finds the PluginManager based on the prototype and invokes it.Proposed solution
I think the easiest way to fix this will be to add an
ENVIRONMENT_INITIALIZER
in theprovideStates
function which loads the PluginManager for that state so that we can ensure that the initialization logic which hydrates the root manager runs.If you want to, I can create a pull request with this solution, or another solution if you guys have a better idea =)
🔥 Exception or Error
There is no exception or error, we just don't get any results
Environment