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