0leg
0leg

Reputation: 14144

Adding conditional pipe() action inside merge()

Case

Using merge() to merge 3 sources of the data on the page:

merge(this.sort.sortChange, this.paginator.page, this.searchQuery$)
      .pipe(
        distinctUntilChanged(),
        switchMap(() => {

Problem

sort and paginator are instant source (user clicks on the control and instantly changes the value. While searchQuery is generated by the text input field.

I would like to add debounceTime(500) but only for the searchQuery$ while keeping other 2 sources included.

How does one achieve this with RxJs?

Upvotes: 0

Views: 84

Answers (1)

frido
frido

Reputation: 14099

You can add operators in a pipe to any Observable.

merge(
  this.sort.sortChange, 
  this.paginator.page, 
  this.searchQuery$.pipe(debounceTime(500))
)

Upvotes: 2

Related Questions