-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
effects_root_module.ts
39 lines (34 loc) · 1022 Bytes
/
effects_root_module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { NgModule, Inject, Optional } from '@angular/core';
import {
StoreModule,
Store,
StoreRootModule,
StoreFeatureModule,
} from '@ngrx/store';
import { EffectsRunner } from './effects_runner';
import { EffectSources } from './effect_sources';
import { ROOT_EFFECTS, _ROOT_EFFECTS_GUARD } from './tokens';
export const ROOT_EFFECTS_INIT = '@ngrx/effects/init';
@NgModule({})
export class EffectsRootModule {
constructor(
private sources: EffectSources,
runner: EffectsRunner,
store: Store<any>,
@Inject(ROOT_EFFECTS) rootEffects: any[],
@Optional() storeRootModule: StoreRootModule,
@Optional() storeFeatureModule: StoreFeatureModule,
@Optional()
@Inject(_ROOT_EFFECTS_GUARD)
guard: any
) {
runner.start();
rootEffects.forEach(effectSourceInstance =>
sources.addEffects(effectSourceInstance)
);
store.dispatch({ type: ROOT_EFFECTS_INIT });
}
addEffects(effectSourceInstance: any) {
this.sources.addEffects(effectSourceInstance);
}
}