0

I am new to Angular and rxjs. Please guide me how can I apply filter to check if data is available in 'measures' before opening the _showMeasureSelectionModal in the following function.

selectMeasure() {
    combineLatest([this.configure.measure$, this.configure.measures$])
      .pipe(
        tap(([measure, measures]) => {
          this._showMeasureSelectionModal(measures, measure)
            .afterClosed()
            .subscribe((opportunities: Opportunity[]) => {
              opportunities && this.configure.updateMeasure(opportunities[0]);
            });
}

Please also explain what each operator is doing and how important is the order?

I tried it in the following way but it gives the following errors in the editor;

  1. Property 'filter' does not exist on type 'Observable<Opportunity[]>'
  2. Binding element 'measure' implicitly has an 'any' type.
  3. Binding element 'measures' implicitly has an 'any' type.
   selectMeasure() {
     combineLatest([this.configure.measure$, this.configure.measures$])
       .pipe(
         this.configure.measures$.filter(([measure, measures]) => { if (measure.length) {   console.log(measure); } })
           .tap(([measure, measures]) => {
            this._showMeasureSelectionModal(measures, measure)
              .afterClosed()
              .subscribe((opportunities: Opportunity[]) => {
                opportunities && this.configure.updateMeasure(opportunities[0]);
                //  this.cohortsAvailable = false;
              });
        }),
        take(1)
      )
      .subscribe();
  }
Tidi
  • 95
  • 1
  • 6
  • What type of measure$ and measures$ objects? and why dont you check the condition before this._showMeasureSelectionModal(measures, measure) line in the tap scope? – ayala Dec 01 '22 at 20:41

0 Answers0