I want to return a boolean from an observable but the return line is executed before the subscribe. How can I do to return the boolean ?
private isLowResolution (file: File): boolean {
this.getImageUri(file).pipe(
mergeMap((imageUri: string) => this.readImage(imageUri)),
mergeMap((image: HTMLImageElement) => of(this.minWidth > image.naturalWidth || this.minHeight > image.naturalHeight))
).subscribe(
(isLow: boolean) => {
this.isLow$.next(isLow);
}
);
return this.isLow$.getValue();
}
I looked at this How do I return the response from an Observable/http/async call in angular? and it don't answer to my question because I can't put the return into the subscribe. If I do that isLowResolution
don't return the boolean anymore and I have and error