To_*_*ars 3 javascript observable rxjs typescript angular
可观察性完成后,我需要向我敬酒,我该怎么做,我的代码是:
this.commerceCtrl.UpdateCategories(this.toSave).subscribe(data => {
}, error => {
this.mainFunction.showError(error)
}),
complete => {
this.mainFunction.showToast(this.localization.message_ok)
}
Run Code Online (Sandbox Code Playgroud)
我试图这样做:
this.commerceCtrl.UpdateCategories(this.toSave).subscribe(data => {
}, error => {
this.mainFunction.showError(error)
}),
() => {
this.mainFunction.showToast(this.localization.message_ok)
}
Run Code Online (Sandbox Code Playgroud)
但这不起作用
您必须将complete处理程序作为第三个参数传递才能进行订阅。
在代码中,只需将右括号移到末尾即可。
更改此代码:
this.commerceCtrl.UpdateCategories(this.toSave).subscribe(data => {
}, error => {
this.mainFunction.showError(error)
}), // <===== Remove this parenthesis
() => {
this.mainFunction.showToast(this.localization.message_ok)
}; // <====== It should be here
Run Code Online (Sandbox Code Playgroud)
对此:
this.commerceCtrl.UpdateCategories(this.toSave).subscribe(
data => {
// next handler body
}, error => {
this.mainFunction.showError(error)
}, () => {
this.mainFunction.showToast(this.localization.message_ok)
}
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
121 次 |
| 最近记录: |