rxjs - 在 switchMap 运算符中过滤 Observable
问题描述
我在维基百科搜索中有一个可观察的
https://ng-bootstrap.github.io/stackblitzes/typeahead/http/stackblitz.html
export class NgbdTypeaheadHttp {
model: any;
searching = false;
searchFailed = false;
myfilter = ['Mary' , 'Maryland'];
constructor(private _service: WikipediaService) {}
search = (text$: Observable<string>) =>
text$.pipe(
debounceTime(300),
distinctUntilChanged(),
tap(() => this.searching = true),
switchMap(term =>
this._service.search(term).pipe(
tap(() => this.searchFailed = false),
catchError(() => {
this.searchFailed = true;
return of([]);
}))
),
tap(() => this.searching = false)
)
}
在管道中的 Switchmap 运算符之后,我想过滤掉响应。
要过滤的项目存储在 myFilter 列表中。
我被困在如何做到这一点上。
解决方案
推荐阅读
- java - Apache Tomcat/9.0.10 while i am trying Compile Error :Files Could not Find Class or Main class
- c - 如何在多显示器配置中获取显示器编号
- java - CrudRepository findById 不返回 java.util。可选的
- node.js - node-fetch 返回未定义的值
- reactjs - 如何正确地将 redux 连接到 react-native
- function - Microsoft Access - 如何更改其行中聚合函数“Totals”的标签
- linux-kernel - 从不调用内核模块探测函数
- c# - 序列化 IRestRequest 以对客户端进行单元测试
- delphi - Delphi Windows service name conflict with project name
- bash - 虽然循环没有停止并读取最后一行(bash)