我正在查看here可用的转换指南,并尝试按照该指南转换在管道中使用的合并,但是它不能像更改前那样工作。
这是我用来学习新合并的代码:
this.form.valueChanges.pipe(
startWith(1),
merge(this.form.statusChanges),
merge(this.click$),
map(() => this.form.value.query),
filter(() => this.form.valid)
)
.subscribe(this.search);
private search = (query: string) => {
this.tvs.search(query).subscribe(shows => this.shows = shows);
}
我试图做这样的事情:
merge(
this.form.valueChanges.pipe(
startWith(1),
map(() => this.form.value.query),
debounceTime(500),
tap(() => this.form.controls.query.errors && console.log(this.form.controls.query.errors)),
tap(() => this.form.status && console.log(this.form.status)),
filter(() => this.form.valid)
), this.form.statusChanges, this.click$)
.subscribe(this.search);
但是在chrome的网络标签中,我正在以查询查询形式等于状态(有效或无效)的api。转换它的正确方法是什么?
答案 0 :(得分:0)
我找到了解决方案:
merge(
this.form.valueChanges,
this.form.statusChanges,
this.click$).pipe(
startWith(1),
map(() => this.form.value.query),
debounceTime(500),
tap(() => this.form.controls.query.errors && console.log(this.form.controls.query.errors)),
tap(() => this.form.status && console.log(this.form.status)),
filter(() => this.form.valid)
).subscribe(this.search);