For my web development project with Angular 9, I needed to add a typeahead feature using ng bootstrap typeahead. The code provided below worked perfectly:
search = (text$: Observable<string>) =>
text$.pipe(
debounceTime(150),
distinctUntilChanged(),
switchMap(term =>
this.GameService.getCode(term).pipe(
catchError(() => {
return of([]);
}))
),
)
However, I encountered an issue when testing in Internet Explorer due to lack of support for arrow functions. To address this problem, I made adjustments to the code as shown below:
search = function(text$: Observable<string>) {
return text$.pipe(
debounceTime(150),
distinctUntilChanged(),
switchMap(term => {
let self = this;
return self.GameService.getCode(term).pipe(
map((res) => {
this.isSearching = false;
return res;
}),
catchError(() => {
return of([]);
}))
}
),
)
}
I now need to find a way to customize this code to ensure compatibility with Internet Explorer.