Platform: Store: Handling of @ngrx/store/update-reducers Action on Startup leads to strange behaviour for initialStates

Created on 12 Mar 2018  路  2Comments  路  Source: ngrx/platform

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request

What is the current behavior?

I configure a object as an initialState for the store. Unfortunately some values are "overridden" on start-up of the store/app.

Expected behavior:

All properties from the initial-state should remain untouched by any internal ngrx-action.

Minimal reproduction of the problem with instructions:

I think my explanation was i bit poor sofar (sorry it's hard to explain this). I think an example will show the problem:

https://stackblitz.com/edit/angular-6wbjq4

In this example everything is fine. The initial state is produced by the initState() function in app/app.state.ts.
screenshot 2018-03-12 18 02 05

BUT:

Remove the key 'featureB' from this init state will "break" this behaviour.

screenshot 2018-03-12 18 03 42

It seems to be caused by the combination function: https://github.com/ngrx/platform/blob/9b02f79f1fc3b5e4d85bf0516108f93eed655126/modules/store/src/utils.ts#L29-L44

The function expects all possible state properties to be setted. If a property is not (in initialState) set the 'hasChanged' turns true and returns the nextState. This is some kind of an intermediated state (at least while the ' @ngrx/store/update-reducers'-Action is fired).

Version of affected browser(s),operating system(s), npm, node and ngrx:

@ngrx/store v 5.1 + 5.2

Other information:

This is not directly linked to the problem but another finding that confused me.
After '@ngrx/store/update-reducers' is fired all reducers are applied, even if they were already applied previously:

screenshot 2018-03-12 18 09 37

Store bug

Most helpful comment

I'm experiencing the same thing with v6.1.0.

All 2 comments

+1 We're seeing the repetition issue here as well on feature stores. The first feature will repeat 3 times, the second one repeats 4 times. Weird. In our case it's not causing any problems.

I'm experiencing the same thing with v6.1.0.

Was this page helpful?
0 / 5 - 0 ratings