Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

85
Visualizações
Combine 3 async to one observable

I have 3 observables that I use for filter html part

Here is typescript part

   fiscalYear$ = this.store$.select(this.tableStoreService.getFiscalYear);
      isLoading$ = this.store$.select(this.tableStoreService.tableSelectors.getLoading);
isReportLoading$ = this.store$.select(isReportLoading);

All of this values has Observable<boolean> in return type.

Then I use it like this to filter html in [disabled]

<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 try to do it like this

get isExportAvialable$() {
    return combineLatest(this.fiscalYear$, this.isLoading$, this.isReportLoading$, (fiscalYear, isLoading, isReportLoading) => isReportLoading || fiscalYear < 2022 || isLoading);
  }

But fiscalYear < 2022 is showing error

How I can combine it to use only one with async?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can solve it like this:

fiscalYear$ = this.store$.select(this.tableStoreService.getFiscalYear);
isLoading$ = this.store$.select(this.tableStoreService.tableSelectors.getLoading);
isReportLoading$ = this.store$.select(isReportLoading);
isExportAvailable$ = combineLatest([
    this.fiscalYear$, 
    this.isLoading$, 
    this.isReportLoading$
]).pipe(map(([year, isLoading, isReportLoading]) => return year < 2022 && isLoading && isReportLoading));

and then just use isExportAvailable$ with the async pipe in your template.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda