3
工作,我有服务:.asObservable不希望与Observable.forkJoin
export class ConfigService {
private _config: BehaviorSubject<object> = new BehaviorSubject(null);
public config: Observable<object> = this._config.asObservable();
constructor(private api: APIService) {
this.loadConfigs();
}
loadConfigs() {
this.api.get('/configs').subscribe(res => this._config.next(res));
}
}
试图从组件称之为:
...
Observable.forkJoin([someService.config])
.subscribe(res => console.log(res)) //not working
someService.config.subscribe(res => console.log(res)) // working
...
如何使用Observable.forkJoin
与Observable
变量config
?
我需要在服务中存储配置,并等待未点亮它们和其他请求未完成停止加载程序。
tywm的答案 – user2886051