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;
- Property 'filter' does not exist on type 'Observable<Opportunity[]>'
- Binding element 'measure' implicitly has an 'any' type.
- 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();
}