I have a variable which changes its value upon an HttpRequest is completed. Its value is false
unless the HttpRequest is finished. Is it possible to use it in a conditional statement? So far I have tried:
async getAsyncValue() {
const loading = await this.dataSource.loading$.toPromise();
if (!loading) {
// do something
}
}
this.dataSource.loading$.subscribe((data) => {
//do something
}
Assuming the loading$ is an observable. You don't really need to convert it to a promise.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.