From 34fb9d036fb2da28ff54b3d3008ff46f52e7c9d1 Mon Sep 17 00:00:00 2001 From: Gabriel Nogueira Date: Sat, 9 Apr 2022 22:18:29 -0300 Subject: [PATCH] :wrench: tratamento de erros nos observables do multi-select --- README.md | 2 +- package.json | 2 +- .../inputs/multi-select/multi-select.component.ts | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e64cdab..ef704cd 100755 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ | Angular Version | NPM Version | |-----------------|-------------| -| 13.2.3 | 13.0.5 | +| 13.2.3 | 13.0.7 | | < 13.0.0 | 0.0.77 | ## Reference diff --git a/package.json b/package.json index 061779c..58bf53b 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mprisma/components", - "version": "13.0.6", + "version": "13.0.7", "repository": { "type": "git", "url": "https://github.com/gabriel-gn/prisma-components.git" diff --git a/src/components/inputs/multi-select/multi-select.component.ts b/src/components/inputs/multi-select/multi-select.component.ts index c233a61..af59337 100644 --- a/src/components/inputs/multi-select/multi-select.component.ts +++ b/src/components/inputs/multi-select/multi-select.component.ts @@ -10,7 +10,7 @@ import { ViewChild } from '@angular/core'; import {FormControl} from '@angular/forms'; -import {concatMap, delay, Observable, of, tap} from 'rxjs'; +import {catchError, concatMap, distinctUntilChanged, Observable, tap, throwError} from 'rxjs'; import {map, startWith} from 'rxjs/operators'; import _ from 'lodash'; import {MAT_AUTOCOMPLETE_DEFAULT_OPTIONS, MatAutocompleteTrigger} from '@angular/material/autocomplete'; @@ -82,7 +82,10 @@ export class MultiSelectComponent implements OnInit, AfterViewInit { if (this.observableInput) { this.filteredOptions = this.myControl.valueChanges.pipe( tap(() => {this.observableInputLoading = true}), - concatMap(() => this.observableInput(`${this.myControl.value}`)), + concatMap(() => this.observableInput(`${this.myControl.value}`).pipe( + distinctUntilChanged(), + catchError(error => {this.observableInputLoading = false; return throwError(error); }), + )), tap(() => {this.observableInputLoading = false}), ); } else {