Search code examples
ngrxngrx-storengrx-effects

ngrx store initiated twice


I noticed that actions are dispatched twice , So I realized the reason was that the store was initiated twice based on this answer : 'Redux - Angular: How prevent actions called twice?'

I tried that in reducer function :

...
default: {
  console.log(action);
  return state;
}

These are the actions :

 {type: "@ngrx/store/init"}

 {type: "@ngrx/effects/init"}

my imports in app.module.ts :

StoreModule.forRoot({ auth: authReducer }),

EffectsModule.forRoot([ AuthEffects ]),

so how I can prevent one of those initiations ??


Solution

  • that's fine and by design, the first one is for reducers and the second one is for effects, because effects are initialized later than the store and it's too later for @ngrx/store/init. therefore in effects initialization is done on @ngrx/effects/init.