combine on synchronous sources from array
See original GitHub issueGiven this code
const a$ = most.from([1,2])
const b$ = most.from([10]);
const c$ = most.combine((a,b)=>a+b, a$, b$);
c$.subscribe({next: c => console.log(c)});
The log shows
12
While most people would expect it to display
11
12
By the way, I’m raising these issues also for xstream https://github.com/staltz/xstream/issues/173 and RxJS https://github.com/ReactiveX/rxjs/issues/2414. Is this is a bug or a feature? I’m not sure. What are people’s ideas and opinions on this case?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
combineLatest on synchronous sources · Issue #2414 - GitHub
Forcing queue scheduling on an operator in JavaScript is like trying to force the library to mimic some sort of gated/threaded model, which...
Read more >Combine framework: how to process each element of array ...
Combine framework: how to process each element of array asynchronously before proceeding ; Fetch info from online database, it's an array · For ......
Read more >Different Methods for Combining Arrays - YouTube
Arrays are an important data structure to learn. In this tutorial we will look at different methods for combining arrays.
Read more >Connecting and merging Combine publishers in Swift
In Combine, the map operator lets us synchronously transform an output value into a new type of value, while the flatMap operator lets...
Read more >Learn to combine RxJs sequences with super intuitive ...
The first operator we'll review is combineLatest . It allows you to take the most recent value from input sequences and transform those...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m ok with saying that the current behavior is correct for 1.x. Like both @trxcllnt and @TylorS have pointed out, values from an array (or other synchronously available data structure) are not really events, they’re simply data, and as such they have no time dimension. There is an implicit time imposed on them based on the instant of observation, but it’s artificial. They’re simultaneous, but indexed.
For now, I think we can say that when given a bunch of simultaneous indexed values, combine() observes the last (“last” as in index order) one.
What I don’t like is that the API allows a user to do get into this situation in the first place. The only way to prevent it currently is to tell users not to do it. Let’s think about ways we can prevent it in the future. The best solution may turn out to be @TylorS’s option 3.
I think there are basically 4 options for these issues (across each library) after some discussion with @briancavalier.
combine
always observes the last (as in order not time) simultaneous event.