Observables: Difference between chaining `pipe` and several function inside a single `pipe`

Viewed 17

Is there a difference between these 2 pieces of codes:

    this.subject
      .pipe(skip(1))
      .pipe(debounceTime(200))
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((value: any) => {
        // Do whatever
      });

And:

    this.subject
      .pipe(skip(1), debounceTime(200), takeUntil(this.unsubscribe))
      .subscribe((value: any) => {
        // Do whatever
      });
1 Answers

The outcomes are equal, however multiple pipes will create multiple new observables which of course has a runtime cost. Whether that cost is negligible in your use case is up to you and your profiling. I would recommend a single pipe as a general rule of thumb.

Related