From 67e073fc8e30897532c547f851ee6594c87fff76 Mon Sep 17 00:00:00 2001 From: athoangmd <36739016+athoangmd@users.noreply.github.com> Date: Thu, 1 Mar 2018 07:30:00 -0500 Subject: [PATCH] feat(typeahead): Allow typeahead to cancel ongoing requests (#3865) fixes #1626 * Allow typeahead to cancel ongoing requests Allow typeahead to cancel ongoing requests when new request is made. feat(typeahead): add possibility of canceling ongoing requests when a new request is sent #1626 * fix(typeahead): fix switchMap import --- src/typeahead/typeahead.directive.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/typeahead/typeahead.directive.ts b/src/typeahead/typeahead.directive.ts index be4eaee2a2..8bb13e2eb8 100644 --- a/src/typeahead/typeahead.directive.ts +++ b/src/typeahead/typeahead.directive.ts @@ -18,6 +18,7 @@ import 'rxjs/add/observable/from'; import 'rxjs/add/operator/debounceTime'; import 'rxjs/add/operator/filter'; import 'rxjs/add/operator/map'; +import 'rxjs/add/operator/switchMap'; import 'rxjs/add/operator/mergeMap'; import 'rxjs/add/operator/toArray'; @@ -343,7 +344,7 @@ export class TypeaheadDirective implements OnInit, OnDestroy { this._subscriptions.push( this.keyUpEventEmitter .debounceTime(this.typeaheadWaitMs) - .mergeMap(() => this.typeahead) + .switchMap(() => this.typeahead) .subscribe((matches: any[]) => { this.finalizeAsyncCall(matches); })