Fixes single and multiple autocomplete's performance.

This commit is contained in:
Diamantis Tziotzios 2019-02-15 13:00:26 +02:00
parent d89aedebc6
commit 7380c55443
2 changed files with 4 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import { Observable, of as observableOf, Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators';
import { AutoCompleteGroup } from '../auto-complete-group';
import { MultipleAutoCompleteConfiguration } from './multiple-auto-complete-configuration';
import { switchMap } from 'rxjs/internal/operators/switchMap';
@Component({
selector: 'app-multiple-auto-complete',
@ -189,7 +190,7 @@ export class MultipleAutoCompleteComponent implements OnInit, MatFormFieldContro
debounceTime(this.requestDelay),
distinctUntilChanged(),
tap(() => { this.loading = true; }),
mergeMap(query => {
switchMap(query => {
// If its a valid object, a selection just made and the object is set as the value of the form control. That means we should fire an extra request to the server.
if (this._isValidObject(query)) { return observableOf([]); }

View File

@ -7,6 +7,7 @@ import { Observable, of as observableOf, Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators';
import { AutoCompleteGroup } from '../auto-complete-group';
import { SingleAutoCompleteConfiguration } from './single-auto-complete-configuration';
import { switchMap } from 'rxjs/internal/operators/switchMap';
@Component({
@ -167,7 +168,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
debounceTime(this.requestDelay),
distinctUntilChanged(),
tap(() => { this.loading = true; }),
mergeMap(query => {
switchMap(query => {
// If its a valid object, a selection just made and the object is set as the value of the form control. That means we should fire an extra request to the server.
if (this._isValidObject(query)) { return observableOf([]); }