I'm using Angular(9) Powered Bootstrap (ng-bootstrap 6.1) and am providing ngbTypeahead with an Observable<IKeyValue[]> like so:
search = (text$: Observable<string>) => {
return text$.pipe(
debounceTime(200),
distinctUntilChanged(),
// switchMap allows returning an observable rather than maps array
switchMap((searchText) => {
if (!searchText || searchText.trim().length < 3) {
// when the user erases the searchText
return EMPTY;
} else {
// get a list of dealer reps
return this.myService.getKeyValues(searchText);
}
})
, catchError((error) => of(this.myService.postErrorMessage(error)))
);
}
I need to transform the output of this.myService.getKeyValues from Observable<IKeyValue[]> to Observable<string[]> by mapping each IKeyValue item to its item.value property.
How do I modify the code above to do that using rxjs 6.5.5?