I am trying to create one library for three similar but still different applications.
I managed to push config with APP name and API endpoint through forRoot
and it looks like this:
import { ModuleWithProviders, NgModule } from '@angular/core';
export interface appConfig {
apiUrl: string;
appName: string;
}
@NgModule({
declarations: [],
exports: []
})
export class TestModule{
static forRoot(config: appConfig): ModuleWithProviders<TestModule> {
console.log(config);
return {
ngModule: TestModule
};
}
}
But now I have three different files with NGRX effects for each application.
I am doing something like this and it works but...:
const effects = [TestEffects, TestEffects1, TestEffects2];
EffectsModule.forFeature(effects)
I wonder if there is a way to use/import only effects that are needed - based on appName
for example.
So if we are in appA then use only TestEffects, if we are using appB then use TestEffects1 etc...
I can do conditions inside the effects file itself but maybe there is a better way? Or maybe my idea is stupid so please let me know.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…