Reputation: 748
I have the following merge(), where I merge the events to send a single request to my API:
merge(
this.sort.sortChange,
this.paginator.page,
this.statusSelect.selectionChange,
this.searchFilterEvent$
)
Now, the first three arguments are the events emitted by Angular Material Directives, the last this.searchFilterEvent$
is an Observable created from fromEvent
which is the keyup event on an input. I want that on each event (except the searchFilterEvent) the code below is executed, but have a debounceTime only on the searchEventFilter, so that I don't send a request on every keyup event.
Is that possible or do I have to separate them and write the code that's executed on the events twice (or in a function and call the function of course)?
Upvotes: 1
Views: 1518
Reputation: 96889
You can just chain the one Observable with debounceTime
and leave the rest as is:
merge(
this.sort.sortChange,
this.paginator.page,
this.statusSelect.selectionChange,
this.searchFilterEvent$.pipe(debounceTime(...)),
)
Upvotes: 3