[英]Import ngrx effects in Angular6
In Angular 6, is it possible to inject the effects with:在 Angular 6 中,是否可以通过以下方式注入效果:
@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.这里不应该使用
providedIn: root
。 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.通过这种方式,您可以将其提供给 Angular 依赖注入树,以便您可以通过构造函数将其注入到您的组件和其他类中。 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.你需要让NGRX了解的影响,并通过发生
EffectsModule.forRoot
或forFeature
功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.