-
Hi, How do I combine multiple inputs (like combineLatest), coalesce their changes over a tick of the event loop and then only emit a single time on the next tick of the loop? Schedulers are a bit confusing to me, so apologies if this should be obvious. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think the closest/easiest is const value$ = timer(0, 1000);
combineLatest([value$, value$, value$])
.pipe(debounceTime(0))
.subscribe((combined) => console.log(combined)); https://stackblitz.com/edit/rxjs-tyrmlz?file=index.ts If you really want "the next tick" you can try writing an operator by yourself. An operator is just a function that takes the previous observable and returns a new one that enhances it. Just use |
Beta Was this translation helpful? Give feedback.
I think the closest/easiest is
debounceTime(0)
. Not sure if it will do exactly "the next tick", because it depends on the implementation, but it should be close enough:https://stackblitz.com/edit/rxjs-tyrmlz?file=index.ts
If you really want "the next tick" you can try writing an operator by yourself. An operator is just a function that takes the previous observable and returns a new one that enhances it. Just use
new Observable(observer =>
constructor.