简体   繁体   English

我应该如何将v5中管道中使用的合并转换为v6

[英]How should I convert merge used in pipe in v5 to v6

I'm looking at the convert guide available here and I'm trying to convert merge used in pipe following this guide, but it is not working as it was before the change. 我正在查看此处提供的转换指南并且我正在尝试按照本指南转换管道中使用的合并,但它不会像更改之前那样工作。

Here is my piece of code I'm using to learn new merge: 这是我用来学习新合并的代码片段:

    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);
  }

I've tried to do something like that: 我试过这样的事情:

    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);

But in network tab in chrome I'm getting the call to api with query equal to status of the form (VALID or INVALID). 但是在chrome的网络选项卡中,我正在调用api,查询等于表单的状态(VALID或INVALID)。 What is the proper way to convert this? 转换它的正确方法是什么?

I found solution for this: 我找到了解决方案:

 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM