-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy patheffects_root_module.ts
More file actions
36 lines (31 loc) · 936 Bytes
/
effects_root_module.ts
File metadata and controls
36 lines (31 loc) · 936 Bytes
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
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 } 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
) {
runner.start();
rootEffects.forEach(effectSourceInstance =>
sources.addEffects(effectSourceInstance)
);
store.dispatch({ type: ROOT_EFFECTS_INIT });
}
addEffects(effectSourceInstance: any) {
this.sources.addEffects(effectSourceInstance);
}
}