-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Meta reducers block initial state #247
Comments
Seems that the problem is in the export function compose(...functions: any[]) {
return function(arg: any) {
if (functions.length === 0) {
return arg;
}
const last = functions[functions.length - 1];
const rest = functions.slice(0, -1);
return rest.reduceRight((composed, fn) => fn(composed), last(arg));
};
} By changing it to the following, the test starts to pass
|
Looking better into it, it's probably the usage of the compose method in |
I added a couple of more tests to investigate the functionality. Seems that in the previous versions of
There was no problem in using the compose function then as the This will start working if we add the initially suggested |
I have the same issue. But it isn't fixed for the current version (4.0.3) My Code:
|
Can this be reopened? Still an issue I think. Cheers, Joel |
Yeah, I'm using ngrx-store-localstorage by @btroncone . It looks here like this metareducer is designed to accept the initial state and override it as necessary...but for some reason the initial state isn't passed into the metareducer whenever I debug. |
Actually I just noticed that this was closed with a fix that went into v4.0.5, but v.4.0.3 is the highest version available on npm? |
@Matmo10 4.0.3 is the latest version of |
@brandonroberts Sure - opened #477 |
Just FYI for anyone who's interested. I work around this by setting the initial state in the reducer. For me it actually makes more sense like this anyway.
|
See: https://ngrx.io/guide/store/recipes/injecting#injecting-feature-config See: https://github.com/ngrx/platform/blob/60633b770e27f6d984abc91a802df5ea9902d80a/modules/store/src/store_module.ts#L89-L93 See: ngrx/platform#247 Injecting a meta reducer factory only works for the root state, per issue 247 above. Injecting the entire configuration through a factory is the correct approach for a feature state.
I'm submitting a...
What is the current behavior?
If adding a single meta reducer, the initial state from the config fails to populate.
Expected behavior:
The initial state should be set in both cases.
Minimal reproduction of the problem with instructions:
Add the following test to
modules.spec.ts
. When adding the simplest no-op meta reducer, the initial state fails to populate.Version of affected browser(s),operating system(s), npm, node and ngrx:
@ngrx/[email protected]
/ master branchThe text was updated successfully, but these errors were encountered: