Skip to content

Commit 065d33e

Browse files
brandonrobertsMikeRyanDev
authored andcommitted
fix(Effects): Ensure StoreModule is loaded before effects (#230)
Closes #184, #219
1 parent f969676 commit 065d33e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

modules/effects/src/effects_feature_module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { NgModule, Inject, Type } from '@angular/core';
1+
import { NgModule, Inject, Optional } from '@angular/core';
2+
import { StoreModule } from '@ngrx/store';
23
import { EffectsRootModule } from './effects_root_module';
34
import { FEATURE_EFFECTS } from './tokens';
45

56
@NgModule({})
67
export class EffectsFeatureModule {
78
constructor(
89
private root: EffectsRootModule,
9-
@Inject(FEATURE_EFFECTS) effectSourceGroups: any[][]
10+
@Inject(FEATURE_EFFECTS) effectSourceGroups: any[][],
11+
@Optional() storeModule: StoreModule
1012
) {
1113
effectSourceGroups.forEach(group =>
1214
group.forEach(effectSourceInstance =>

modules/effects/src/effects_root_module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { NgModule, Inject } from '@angular/core';
1+
import { NgModule, Inject, Optional } from '@angular/core';
2+
import { StoreModule } from '@ngrx/store';
23
import { EffectsRunner } from './effects_runner';
34
import { EffectSources } from './effect_sources';
45
import { ROOT_EFFECTS } from './tokens';
@@ -8,7 +9,8 @@ export class EffectsRootModule {
89
constructor(
910
private sources: EffectSources,
1011
runner: EffectsRunner,
11-
@Inject(ROOT_EFFECTS) rootEffects: any[]
12+
@Inject(ROOT_EFFECTS) rootEffects: any[],
13+
@Optional() storeModule: StoreModule
1214
) {
1315
runner.start();
1416

0 commit comments

Comments
 (0)