我正在尝试使用of
,但我的编辑器说它已被弃用。如何使用of
使其正常工作
public save(): Observable<ISaveResult> | Observable<boolean> {
if (this.item) {
return this.databaseService.save(this.userId, this.item)
}
return of(false)
}
public componentSave() {
const sub = this.userService
.save()
.subscribe(val => {
// This callback shows the below error in the editor
})
}
当我使用它时,我在我的编辑器中得到以下错误:
@deprecated — Use an observer instead of a complete callback
'(next: null, error: (error: any) => void, complete: () => void): Subscription' is deprecated
Expected 2-3 arguments, but got 1.
发布于 2020-12-01 11:28:53
不要紧,我想我找到问题了。将save函数的返回类型从
public save(): Observable<ISaveResult> | Observable<boolean>
至
public save(): Observable<ISaveResult | boolean>
https://stackoverflow.com/questions/65083599
复制相似问题