K✔
load() всегда возвращал промисSize: a a a
K✔
load() всегда возвращал промисS
S
load() всегда возвращал промисAV
AV
K✔
S
B
B
B
S
AV
S
K✔
constructor() { this.load() }
public load(): Promise<any> {
return this.http.get(url)
.toPromise()
.then(() => {});
}
Observable.
public configLoaded = new Observable<boolean>(subscriber => {
const loaded = this.config ? true : false;
subscriber.next(loaded);
});
constructor(private http: HttpClient) {
this.load();
}
public load(): Promise<any> {
return this.http.get(url)
.toPromise()
.then((config: Config) => {
this.config = config;
this.configLoaded.pipe(
map(configLoaded => {
configLoaded = this.config ? true : false;
})
);
});
}
ConfigLoaded всегда falseS
public configLoaded = new Observable<boolean>(subscriber => {
const loaded = this.config ? true : false;
subscriber.next(loaded);
});
constructor(private http: HttpClient) {
this.load();
}
public load(): Promise<any> {
return this.http.get(url)
.toPromise()
.then((config: Config) => {
this.config = config;
this.configLoaded.pipe(
map(configLoaded => {
configLoaded = this.config ? true : false;
})
);
});
}
ConfigLoaded всегда falseK✔
load() по-прежнему даёт промисS
B
B