Skip to content

Combine and emit once? #7239

Answered by voliva
thatcort asked this question in Q&A
Mar 29, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

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:

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 new Observable(observer => constructor.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@thatcort
Comment options

Answer selected by thatcort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants