简体   繁体   中英

Import ngrx effects in Angular6

In Angular 6, is it possible to inject the effects with:

 @Injectable({
        providedIn: 'root'
    })

?

So far I imported effects this way:

imports: [
    StoreModule.forRoot('someFeature', reducers),
    EffectsModule.forRoot([SomeEffects])
],

With the new way is it possible to inject effects as well or only regular services?

It should not be possible to use providedIn: root here. In this way you'd provide it to the Angular Dependency Injection Tree so that you can inject it in your components and other classes via the constructor. But that is not what you want to do. You need to make NgRX know about the effects, and that is happening via the EffectsModule.forRoot or forFeature functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM