Platform: @ngrx/store/update-reducers called multiple times

Created on 8 Sep 2018  路  5Comments  路  Source: ngrx/platform

When the app starts, the console log from the browser showed multiple times that they are called by store.

I don't know why the update-reducers from store is called multiple times.
AuthStore is called 1 time for init and 3 times for update-reducers. BooksStore is called 1 time for init and 5 times for update-reducers

I expected log message for each module which will only show one time when the module is initialized.
What happened if I have more than 2 store. How many times is showed in console log on browser when the app starts. Is it effected to speed of project ?

Most helpful comment

Never mind, it was issue with Redux Devtool.
For someone searching for this issue, remove StoreDevtoolsModule and test again.

All 5 comments

It's called for each new StoreModule.forFeature that registers a reducer. This has been updated with the next major release to group the registered modules together into one update call. See https://github.com/ngrx/platform/pull/1240

1240 covers multiple features registering together, but there are issue about registering same feature multiple times. I have two lazy loaded modules, and update-reducers is called about 10 time when the module is loaded. It is causing a very serious impact on performance for me.

Never mind, it was issue with Redux Devtool.
For someone searching for this issue, remove StoreDevtoolsModule and test again.

Is there anything we can do about this? A lot of us rely on StoreDevtoolsModule for debugging, and this really muddies up the output.

From what I've observed, when you have non-lazily-loaded modules using Store.forFeature, the @ngrx/store/update-reducers action seems to be fired every time a lazily-loaded module loads (regardless of whether or not that lazily loaded module uses Store.forFeature itself).

e.g. If I have NonLazilyModuleWithStore0, LazyModuleWithStore1, LazyModuleWithStore2, LazyModuleWithoutStoreA, and LazyModuleWithoutStoreB, the content of action.features in @ngrx/store/update-reducers is as follows:

  • On homepage load (no lazy modules loaded yet) -> [ "nonLazyKey0" ]
  • On LazyModuleWithStore1 load -> ["nonLazyKey0", "lazyKey1"]
  • On LazyModuleWithoutStoreA load -> [ "nonLazyKey0" ]
  • On LazyModuleWithoutStoreB load -> [ "nonLazyKey0" ]
  • On LazyModuleWithStore2 load -> ["nonLazyKey0", "lazyKey2"]
  • etc.

So it would seem that the non-lazy module is not removing itself from this action, and is even causing actions to be fired that should not be fired at all (in the case of lazy modules without any associated store).

This is what happens with dev tools

image (2)

This is what happens without

image (3)

At first I thought it was a bug in a meta reducer or something, but apparently it's a bug in devtools. Can this be re-opened or can we do something about this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alvipeo picture alvipeo  路  3Comments

axmad22 picture axmad22  路  3Comments

NathanWalker picture NathanWalker  路  3Comments

brandonroberts picture brandonroberts  路  3Comments

gperdomor picture gperdomor  路  3Comments