如何停止等待最后订阅并显示烤面包机'this.toasterService.pop('成功','电子邮件','
现在,在更改changePassword()之后,accountService.getAll()会复制, 需要在sendEmail()
之后
this.busy = this.accountService.getAll().subscribe(
return this.changePassword().add(() => this.sendEmail());
});
changePassword() {
return this.accountService.update(this.account).subscribe(
response => response,
e => this.toasterService.pop('error', 'Change Password', e.error.message))
;
}
sendEmail() {
return this.accountService.sendPasswordEmail(this.account).subscribe(
(response : any) => this.toasterService.pop('success', 'Email', 'Email has been sent, successfully!'),
(e) => this.toasterService.pop('error', 'Email', e.error.message))
;
}
答案 0 :(得分:0)
尝试以下和check how to handle multiple request here
async getAllAccounts() {
//this will wait till get all account
this.busy = await this.accountService.getAll().toPromise();
//this will complete other operation without wait
this.changePAssword();
}
changePassword() {
return this.accountService.update(this.account).pipe(
tap(() => add(() => this.sendEmail()))
).subscribe(
response => response,
e => this.toasterService.pop('error', 'Change Password', e.error.message));
}