【发布时间】:2020-08-16 10:16:23
【问题描述】:
我有 BehaviorSubject 属性
public results$ = new BehaviorSubject(null);
假设我订阅了这个
this.results$.subscribe(() => this.find());
每次在输入元素内按键盘上的任意键时都会调用订阅。因此,为了防止对服务器的许多请求,我添加了 debounceTime()
this.results$
.pipe(debounceTime(500))
.subscribe(() => this.find());
但我需要立即调用第一个 this.find() 而不进行任何反跳。
我该怎么做?
【问题讨论】:
标签: angular rxjs behaviorsubject