I have 3 different observables that I am using to filter the HTML content.
Here is the TypeScript code snippet:
fiscalYear$ = this.store$.select(this.tableStoreService.getFiscalYear);
isLoading$ = this.store$.select(this.tableStoreService.tableSelectors.getLoading);
isReportLoading$ = this.store$.select(isReportLoading);
All of these observables return a type of Observable<boolean>
.
I then use them in filtering the HTML elements with the [disabled]
attribute like so:
<button class="btn btn-primary font-weight-700 font-size-200" [disabled]="(isReportLoading$ | async) || (fiscalYear$ | async) < 2022 || (isLoading$ | async) " (click)="clickExport()">
{{ 'homepage.export' | translate }}
<mat-icon class="btn-icon export-icon" svgIcon="export"></mat-icon>
</button>
I attempted to combine these observables into one using the following approach:
get isExportAvialable$ {
return combineLatest(this.fiscalYear$, this.isLoading$, this.isReportLoading$, (fiscalYear, isLoading, isReportLoading) => isReportLoading || fiscalYear < 2022 || isLoading);
}
However, I encountered an error with the condition fiscalYear < 2022
.
Can you suggest a way to combine these observables into a single one using asynchronous operations?