Buffered combineLatest
#7461
Replies: 3 comments 2 replies
-
Your example has 3 sources which are combined with combineLatest, and then each source emits synchronously which results in three emits from the combineLatest with one value updating at a time: Typical combineLatest. Your fix buffers all synchronously emitted values by using a bufferTime(0), and then only emits the last value of all the accrued buffered values resulting in: You solution looks clean enough. I don't think the maintainers are open to adding more functionality to rxjs, as they are happy that people can solve their own problems using the existing functionality. What I am left wondering is that maybe what you want is signals and not an observable? Because you aren't interested in all emitted values, but only the end result which you probably want to show to the user. This is what signals are for, they are inherently lossy like this. |
Beta Was this translation helpful? Give feedback.
-
You can just use |
Beta Was this translation helpful? Give feedback.
-
Small note, you could use |
Beta Was this translation helpful? Give feedback.
-
When multiple
combineLatest
sources emit at the same time (from an async perspective), I want the next emission ofcombineLatest
to include the latest emissions from all of the sources. This is a pretty common use case in applications: where multiple subscribed pieces of state are updated from a single API call and a component will want to see updated data from all pieces of state (not just whichever one happens to win the race condition). Plus this will improve performance by reducing the rerenders fromn
pieces of subscribed state to just1
.So I wrote a simple wrapper for
combineLatest
which accomplishes this. My question is, is there a creation function or operator already in rxjs that does this and if not, will you consider adding this feature?Beta Was this translation helpful? Give feedback.
All reactions