从服务器收到AppConfigService响应后,如何在AppModule中注册CompanyEffects。
在AppModule中进行效果注册
EffectsModule.forRoot([CompanyEffects]),
CompanyEffects
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
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;
}
}
答案 0 :(得分:0)
没有办法。
您只能更新CompanyEffects
来跳过/延迟操作,直到出现this.env.appConfig
为止。