Skip to content

Commit

Permalink
🔧 tratamento de erros nos observables do multi-select
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-gn committed Apr 10, 2022
1 parent 6e77622 commit 34fb9d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
7 changes: 5 additions & 2 deletions src/components/inputs/multi-select/multi-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand Down

1 comment on commit 34fb9d0

@vercel
Copy link

@vercel vercel bot commented on 34fb9d0 Apr 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.