I have two applications in a mono-repo, one will be a free subset of the other, so all of the functionality in the free one is included in the not-free one.
I'm trying to set up my Effects so that there is a core effect class that implements all of the common effects and then extend that in the not-free project to add additional effects. This isn't working. Both apps can use the core effects as long as that's all the effects I define, but as soon as I add more effects to the class for the not-free, it stops recognizing the core effects.
Here's the set up:
- core.effects.ts includes the CoreEffects class which defines 2 vanilla effects - LoadLayout and ToggleSidebar
- not-free.effects.ts includes NotFreeEffects class which extends CoreEffects class
- free.effects.ts includes FreeEffects class which extends CoreEffects class and does not define any additional effects.
- In my module, I import Effects module and specify the inherited effects class:
EffectsModule.forRoot([NotFreeEffects])
andEffectsModule.forRoot([FreeEffects])
. If I'm understanding this correctly, this means that my inherited classes are set up correctly as the Core Effects are still seen (unless I define other Effects in the inherited class)
As an example, the LoadLayout effect looks like this (the others are similar):
@Effect()
loadLayout$: Observable<Action> = this.actions$
.ofType(CoreLayoutActions.LOAD_LAYOUT)
.switchMap(() => this.layoutService.loadLayout())
.map(
(layoutState: ICoreLayoutState) =>
new CoreLayoutActions.LoadLayoutSuccessAction(layoutState)
);
When I run either app with this set up, everything works. I added log statements in my reducers so I could see when the LoadLayoutSuccess message is passed and handled in the reducer.
As soon as I add another effect to the NotFreeEffect class (i.e. one not used by the free app), the core Effects are no longer handled - my log statements in the reducers no longer indicate that LoadLayoutSuccess is ever dispatched. Nothing has changed except adding a totally unrelated Effect to the not-free class. The free app continues to work, the not-free does not. If I remove that additional Effect from not-free, it begins recognizing the Core Effects again.
What am I missing? Should you be able to inherit effect classes like this?
Details:
- Angular CLI: 1.7.1
- Node: 8.9.4
- OS: win32 x64
Angular: 5.2.7 ... animations, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router
@angular/cdk: 5.2.5
- @angular/cli: 1.7.1
- @angular/material: 5.2.5
- @angular-devkit/build-optimizer: 0.3.2
- @angular-devkit/core: 0.3.2
- @angular-devkit/schematics: 0.3.2
- @ngtools/json-schema: 1.2.0
- @ngtools/webpack: 1.10.1
- @schematics/angular: 0.3.2
- @schematics/package-update: 0.3.2
- typescript: 2.6.2
- webpack: 3.11.0
- ngrx: 5.2.0
- @nrwl/nx: 1.0.3
Thanks,
TTE