Skip to content

Commit

Permalink
feat(typeahead): Allow typeahead to cancel ongoing requests (#3865)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
athoangmd authored and valorkin committed Mar 1, 2018
1 parent 0d6882f commit 67e073f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/typeahead/typeahead.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
})
Expand Down

0 comments on commit 67e073f

Please sign in to comment.