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' ;
5
4
6
5
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' ) ;
8
7
9
- @NgModule ( { } )
8
+ @NgModule ( {
9
+ providers : [
10
+ {
11
+ provide : Actions ,
12
+ useValue : actions
13
+ }
14
+ ]
15
+ } )
10
16
export class EffectsNgModule {
11
17
constructor (
12
18
@Inject ( EFFECTS_MANAGER ) manager : EffectsManager ,
@@ -17,7 +23,7 @@ export class EffectsNgModule {
17
23
18
24
flattenProviders . forEach ( provider => {
19
25
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 ) ) ;
21
27
22
28
registerEffects ( effects as Effect [ ] ) ;
23
29
} ) ;
@@ -35,10 +41,6 @@ export class EffectsNgModule {
35
41
provide : EFFECTS_MANAGER ,
36
42
useFactory : ( ) => initEffects ( config )
37
43
} ,
38
- {
39
- provide : Actions ,
40
- useValue : actions
41
- } ,
42
44
...providers ,
43
45
{
44
46
provide : EFFECTS_PROVIDERS ,
@@ -57,7 +59,6 @@ export class EffectsNgModule {
57
59
58
60
}
59
61
60
-
61
62
function flatten < T > ( arr : T [ ] ) : T [ ] {
62
63
return arr . reduce ( ( acc , cur ) => acc . concat ( Array . isArray ( cur ) ? flatten ( cur ) : cur as any ) , [ ] ) ;
63
- } ;
64
+ } ;
0 commit comments