You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is that TreeService is an abstract class and i would like to provide an implementation provided directly by my module... However, even if my module provide something like this :
The instanciation of the TreeNodeEffects fail on injection of the abstract service, angular is not able to provide the concrete implementation. The others dependencies are correctly injected. However, if i change the constructor of the effect to the concrete class, the injection is done but it make my effect hard bound to the concrete type...
Describe any alternatives/workarounds you're currently using
I managed to realize the injection by doing this :
import{ɵngrx_modules_effects_effects_e}from'@ngrx/effects';imports: [EffectsModule.forFeature([...fromStore.effects]),//here i import my other effects],providers: [{provide: TreeService,useClass: TestCaseWorkspaceService},{provide : ɵngrx_modules_effects_effects_e,useFactory : (actions$,service)=>{return[newTreeNodeEffects(TEST_CASE_WORKSPACE_ROOT_URL,MAIN_TREE_ID,actions$,service)];},deps : [Actions,TreeService],multi : true}
Basically, i used the exported FEATURE_EFFECTS token, however the exported name 'ɵngrx_modules_effects_effects_e' suggest that it's not an official API, so i'm relectant to use it in my application...
This token is used in ngrx forFeature method in platform/modules/effects/src/effects_module.ts
@NgModule({})exportclassEffectsModule{staticforFeature(featureEffects: Type<any>[]): ModuleWithProviders<EffectsFeatureModule>{return{ngModule: EffectsFeatureModule,providers: [featureEffects,{provide: FEATURE_EFFECTS,multi: true,deps: featureEffects,//<-- maybe we should be able to provide deps here ?useFactory: createSourceInstances,},],};}
Other information:
I'm sorry if i missed something, i'm new to angular/ngrx and i'm definitly not an expert with angular injection system. But it seems to me that ngrx should have an official way to provide explicit dependencies to effects...
Maybe it's just changing the exported name of the token and add some documentation ?
Thank you for your attention
The text was updated successfully, but these errors were encountered:
@j-thebault Hey, i know this is old for quite some time, but have you found a solution for this? Otherwise i would have to create another issue for this, because i need this :D
Hello
I'm trying to create a reusable effect. This effect use some constant and a service :
The problem is that TreeService is an abstract class and i would like to provide an implementation provided directly by my module... However, even if my module provide something like this :
The instanciation of the TreeNodeEffects fail on injection of the abstract service, angular is not able to provide the concrete implementation. The others dependencies are correctly injected. However, if i change the constructor of the effect to the concrete class, the injection is done but it make my effect hard bound to the concrete type...
Describe any alternatives/workarounds you're currently using
I managed to realize the injection by doing this :
Basically, i used the exported FEATURE_EFFECTS token, however the exported name 'ɵngrx_modules_effects_effects_e' suggest that it's not an official API, so i'm relectant to use it in my application...
This token is used in ngrx forFeature method in platform/modules/effects/src/effects_module.ts
Other information:
I'm sorry if i missed something, i'm new to angular/ngrx and i'm definitly not an expert with angular injection system. But it seems to me that ngrx should have an official way to provide explicit dependencies to effects...
Maybe it's just changing the exported name of the token and add some documentation ?
Thank you for your attention
The text was updated successfully, but these errors were encountered: