Fixes single and multiple autocomplete's performance.
This commit is contained in:
parent
d89aedebc6
commit
7380c55443
|
@ -7,6 +7,7 @@ import { Observable, of as observableOf, Subject } from 'rxjs';
|
||||||
import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators';
|
import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators';
|
||||||
import { AutoCompleteGroup } from '../auto-complete-group';
|
import { AutoCompleteGroup } from '../auto-complete-group';
|
||||||
import { MultipleAutoCompleteConfiguration } from './multiple-auto-complete-configuration';
|
import { MultipleAutoCompleteConfiguration } from './multiple-auto-complete-configuration';
|
||||||
|
import { switchMap } from 'rxjs/internal/operators/switchMap';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-multiple-auto-complete',
|
selector: 'app-multiple-auto-complete',
|
||||||
|
@ -189,7 +190,7 @@ export class MultipleAutoCompleteComponent implements OnInit, MatFormFieldContro
|
||||||
debounceTime(this.requestDelay),
|
debounceTime(this.requestDelay),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
tap(() => { this.loading = true; }),
|
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 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([]); }
|
if (this._isValidObject(query)) { return observableOf([]); }
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { Observable, of as observableOf, Subject } from 'rxjs';
|
||||||
import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators';
|
import { debounceTime, distinctUntilChanged, map, mergeMap, startWith, tap } from 'rxjs/operators';
|
||||||
import { AutoCompleteGroup } from '../auto-complete-group';
|
import { AutoCompleteGroup } from '../auto-complete-group';
|
||||||
import { SingleAutoCompleteConfiguration } from './single-auto-complete-configuration';
|
import { SingleAutoCompleteConfiguration } from './single-auto-complete-configuration';
|
||||||
|
import { switchMap } from 'rxjs/internal/operators/switchMap';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -167,7 +168,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
|
||||||
debounceTime(this.requestDelay),
|
debounceTime(this.requestDelay),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
tap(() => { this.loading = true; }),
|
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 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([]); }
|
if (this._isValidObject(query)) { return observableOf([]); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue