Skip to content

Commit 72b0a98

Browse files
committed
chore(*): move actions provider into providers of ng module
1 parent c084727 commit 72b0a98

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

libs/effects-ng/src/lib/effects-ng.module.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import { Inject, InjectionToken, Injector, ModuleWithProviders, NgModule, Type } from '@angular/core';
2-
import { Effect, EffectsConfig, initEffects, registerEffects, EffectsManager, isEffect } from '@ngneat/effects';
3-
import { Actions } from './actions';
4-
import { actions } from '@ngneat/effects';
1+
import { Inject, InjectionToken, Injector, ModuleWithProviders, NgModule, Type } from '@angular/core';
2+
import { actions, Effect, EffectsConfig, EffectsManager, initEffects, isEffect, registerEffects } from '@ngneat/effects';
3+
import { Actions } from './actions';
54

65
const EFFECTS_PROVIDERS = new InjectionToken('EFFECTS_PROVIDERS');
7-
const EFFECTS_MANAGER = new InjectionToken("@ngneat/effects Effects Manager")
6+
const EFFECTS_MANAGER = new InjectionToken('@ngneat/effects Effects Manager');
87

9-
@NgModule({})
8+
@NgModule({
9+
providers: [
10+
{
11+
provide: Actions,
12+
useValue: actions
13+
}
14+
]
15+
})
1016
export class EffectsNgModule {
1117
constructor(
1218
@Inject(EFFECTS_MANAGER) manager: EffectsManager,
@@ -17,7 +23,7 @@ export class EffectsNgModule {
1723

1824
flattenProviders.forEach(provider => {
1925
const instance = injector.get(provider);
20-
const effects = Object.values(instance).filter((v: any) => isEffect(v));
26+
const effects = Object.values(instance).filter((v: any) => isEffect(v));
2127

2228
registerEffects(effects as Effect[]);
2329
});
@@ -35,10 +41,6 @@ export class EffectsNgModule {
3541
provide: EFFECTS_MANAGER,
3642
useFactory: () => initEffects(config)
3743
},
38-
{
39-
provide: Actions,
40-
useValue: actions
41-
},
4244
...providers,
4345
{
4446
provide: EFFECTS_PROVIDERS,
@@ -57,7 +59,6 @@ export class EffectsNgModule {
5759

5860
}
5961

60-
6162
function flatten<T>(arr: T[]): T[] {
6263
return arr.reduce((acc, cur) => acc.concat(Array.isArray(cur) ? flatten(cur) : cur as any), []);
63-
};
64+
};

0 commit comments

Comments
 (0)