How can I incorporate CompanyEffects in my AppModule after receiving a response from the AppConfigService on the server?
Effect registration within AppModule
EffectsModule.forRoot([CompanyEffects]),
CompanyEffects Implementation
export class CompanyEffects {
constructor(
private actions$: Actions,
private companyService: CompanyService,
private env: AppConfigService,
) {
}
}
@Effect()
loadTeams$: Observable<any> = this.actions$.pipe(
ofType(companyActions.CompanyActionsTypes.ALL_TEAMS_REQUEST),
mergeMap(() =>
this.companyService.teamList().pipe(
...
)
));
AppConfigService Setup
export class AppConfigService {
public appConfig: AppConfig;
constructor(private injector: Injector) { }
loadAppConfig(): Promise<any> {
const http = this.injector.get(HttpClient);
let configUrl = "/api/data/config";
const promise = http
.get(configUrl)
.toPromise()
.then((data: AppConfig) => {
this.appConfig = data;
return data;
});
return promise;
}
}