Skip to content

Commit

Permalink
(fix): Suggestions should not make subsequent. Fixes #19
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Dec 12, 2017
1 parent 970f8e1 commit 6ea4dd8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/typeahead.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {
} from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import 'rxjs/add/observable/from';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/take';
import 'rxjs/add/operator/toArray';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/share';
import 'rxjs/add/operator/mergeAll';
import 'rxjs/add/operator/publishReplay';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { TypeaheadSettings, TypeaheadSuggestions } from './typeahead.interface';

Expand Down Expand Up @@ -224,10 +224,13 @@ export class TypeaheadComponent implements ControlValueAccessor, AfterViewInit,
*/
ngOnInit() {
this.suggestionsInit(this.suggestions instanceof Observable ?
this.suggestions.mergeMap((value: any[]) => {
return Observable.from(value);
}) :
Observable.from(this.suggestions));
(<Observable<any>> this.suggestions)
.publishReplay(1)
.refCount()
.mergeAll() :
Observable
.of(...this.suggestions)
);
this.toggleDropdown(false);
this._inputChangeEvent.emit('');
}
Expand Down

0 comments on commit 6ea4dd8

Please sign in to comment.