I have an observable that makes an API call. The API call returns an array of objects in the response.
I am using this observable in multiple places. In most cases, I want the object in the response.
However, in the case of CanDeactivate, I need to 'pre-process' the response to return true or false instead, since CanDeactivate is expected to return Observable.
Is there a way to tap into the response to process it ahead of time (perhaps using the 'tap' operation?)
canDeactivate(): Observable<boolean> | boolean {
// Check if Is Being Edited must be removed
if (this.mustReleaseIsBeingEdited()) {
return this.updateIsBeingEdited$(false);
} else {
return of(true);
}
}
public updateIsBeingEdited$(_id: string, IsBeingEdited: boolean): Observable<Record[]> {
return this.httpService!.postData(
`records/_id/${_id}/IsBeingEdited/${IsBeingEdited}`,
{}
);
}