简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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