My autocomplete function is set up like this:
chooseArtist: OperatorFunction<string, readonly string[]> = (text$: Observable<string>) =>
text$.pipe(
debounceTime(200),
distinctUntilChanged(),
map((term: any) => term.length < 2 ? []
: this.artistlookuplist.filter((v: any) => v.name.toLowerCase().indexOf(term.toLowerCase()) > -1).slice(0, 10))
)
I also have a service that loads the artistlookuplist
like this:
getArtists(): void {
this.artistService.getSearchArtist(this.searchstring).subscribe((data: any[]) => {
this.artistlookuplist = data;
});
I want to integrate these two processes so that the autocomplete suggestions are only fetched when the chooseArtist
function is triggered from the autocomplete field.
Any solutions on how to achieve this?