[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
Initial state is not passed to meta reducers during @ngrx/store/init
Initial state should be passed to meta reducers during @ngrx/store/init, especially for libraries like ngrx-localstorage-sync which need to merge any supplied initial state with values saved in local storage, for example (see https://github.com/btroncone/ngrx-store-localstorage/blob/master/src/index.ts#L180).
https://stackblitz.com/edit/angular-c8kl8z
If you run the stackblitz, you'll see that state is undefined inside the logger metareducer during @ngrx/store/init (check the console, or debug if you want)
"@ngrx/router-store": "^4.0.4",
"@ngrx/store": "^4.0.3",
Awesome, thanks for the fix @brandonroberts ! Any idea when this will hit npm? cc @MikeRyanDev
We are going to be releasing Entity in the next couple of days. Will probably publish everything else with it.
Does 100a8ef also cover feature modules? I'm not sure if i'm doing something wrong, but the meta-reducer spec fails if you apply this patch
diff --git a/modules/store/spec/modules.spec.ts b/modules/store/spec/modules.spec.ts
index 190c8b1..44feacb 100644
--- a/modules/store/spec/modules.spec.ts
+++ b/modules/store/spec/modules.spec.ts
@@ -129,7 +129,8 @@ describe(`Store Modules`, () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
- StoreModule.forRoot(reducerMap, { initialState, metaReducers }),
+ StoreModule.forRoot({}, { metaReducers: [] }),
+ StoreModule.forFeature("core", reducerMap, { initialState, metaReducers }),
],
});
@@ -138,7 +139,7 @@ describe(`Store Modules`, () => {
it('should have initial state', () => {
store.take(1).subscribe((s: any) => {
- expect(s).toEqual(initialState);
+ expect(s.core).toEqual(initialState);
});
});
};
........................................................................................................................................................................F.............................................
Failures:
1) Store Modules : With initial state should add initial state with registered meta-reducers should have initial state
Message:
Expected $.fruit = 'apple' to equal 'banana'.
Most helpful comment
We are going to be releasing Entity in the next couple of days. Will probably publish everything else with it.