-2

I have two different subject subscriptions for different events which call the same function

subject1.subscribe(
_ => callFunction();
);

subject2.subscribe(
_ => callFunction();
);

i need that callFunction () is not to be invoked more than once every second, how can i do this behavior with rxjs?

Andrea Scarafoni
  • 937
  • 2
  • 13
  • 26
  • 1
    Possible duplicate of [Angular and debounce](https://stackoverflow.com/questions/32051273/angular-and-debounce) – Jamie Rees Mar 25 '19 at 11:07

1 Answers1

2

You have to combine your observables. If they're finished, use forkJoin, else combineLatest :

combineLatest(s1, s2).pipe(debounceTime(1000)).subscribe(([r1, r2]) => ...);