【发布时间】:2022-01-04 21:23:21
【问题描述】:
我正在尝试实现 rxjs 函数 distinctUntilChanged 但没有工作...
public searchVal(val: string) {
this.suggestions = (new Observable((observer: Observer<string>) => {
observer.next(val);
})).pipe(
takeUntil(this.destroy$),
distinctUntilChanged(),
switchMap((query: string) => {
if (query) {
console.log('query query' , query)
}
return of([]);
})
);
}
但这不起作用我不知道为什么?我也设置了 debounceTime 但它也不起作用?
我的计划是不发送相同的值。
【问题讨论】:
-
你订阅了吗?
标签: angular typescript rxjs