-
-
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
Ngrx/store/init is Fired Twice (with sub-modules) #133
Comments
Can you reproduce this in a plunker or repo? Thanks |
Just opened the example app, it console logs the "@ngrx/store/init" action 3 times. |
@brandonroberts I think @generalcss is right, the example app will exhibit the same behaviour. I used StoreModule.forFeature() with my app and I had the same results. I think the example app may be sufficient for reproducing the behaviour, but do you have a working v4 plunker I could modify? |
@kesarion yes, there is a plunker link in the issue template: http://plnkr.co/edit/tpl:757r6L |
@brandonroberts You were missing |
Here is the plunker: http://plnkr.co/edit/GRUlzV8xMNsDsf0Jjb97 Personally, for me, the problem is dispatching an action before lazy loaded store is initialized, somehow this way the action is being handled twice. See src/app.component.ts line 27 - "ADD" action is dispatched once, but logging meta reducer logs that action twice (the second time is after lazy loaded store init) and, after everything settles, the state has two "things" instead of one. Afterwards dispatching actions works as expected. |
Hmm... I think this is directly related to this issue #229. Wish I'd seen it earlier! |
@karptonite @brandonroberts I can confirm, this happens only with Devtools. Commenting out Devtools in the app module fixes the issue, which means this won't be an issue in production environments 😉 Since this is cleared up and will be handled in #229, I think we can close this one. |
this still happens with devtools thus it poses a problem when debugging during development. then the second init is fired the previous actions get completely wiped. I think this needs to be reopened |
Possibly related to ngrx/store#280.
I'm getting @ngrx/store/init once for the app module and again for other modules;
it doesn't seem to matter whether they're loaded eagerly or lazily(it's happening only when lazy loading now).This wouldn't normally be a problem, but when you navigate from a page to one from another module, the re-init causes the last state to be sent again to all subscriptions, so in my case, for example, I have a subscription to new notifications and if there was a notification on the previous page I receive it again. That's not ok.
I extended the app store with a new reducer using
store.addReducer()
, store being a Store with an extended state. Everything else works as expected.I'm also using the router-store, effects and store-devtools, all v4.*.
Is there any way around this issue?
Thanks!
The text was updated successfully, but these errors were encountered: