I am trying to use of
but my editor is saying that it is deprecated. How can I get this to working using 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
})
}
When I use this, I get the following error in my 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.
Never mind I think I found the problem. Change the return type of the save function from
public save(): Observable<ISaveResult> | Observable<boolean>
to
public save(): Observable<ISaveResult | boolean>
I am actually not using a return type. I'm just using it in the question. It is actually inferred from the return values.
Well then I go back to my original comment. You need to provide an example with the actual code that is broken.
If I don't inferre the return, it then works properly, thanks