Implement "withLatestFrom" as an extra operator
See original GitHub issueI’m looking for a method to accomplish:
--1----2-----3--------4---
----a-----b-----c--d------
combineLeft
--1?---2a----3b-------4d--
I believe that it is called withLatestFrom
in RxJS. I think it is a really common case in cycle.js development.
For now, I’m using:
let withLatestFrom = (a, b) => {
let c = xs.create()
let bValue = ''
b.addListener({
next: v => { bValue = v },
error: () => {},
complete: () => {}
})
a.addListener({
next: v => c.shamefullySendNext([v, bValue]),
error: () => {},
complete: () => {}
})
return c
}
- Is it possible, to easly compose it from existing operators?
- Maybe it could be implemented as an extra?
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Combine: WithLatestFrom operator - Medium
In this post, we'll walk through how in the RP paradigm with Combine we can implement one practical case: presenting content with the...
Read more >Practical Examples to Explain forkJoin, zip, withLatestFrom ...
Each time the value of the control changes,the operator returns an observable which emits the updated value of the control. This valueChanges property...
Read more >withLatestFrom() RxJS - The Simplest Way to Join ... - YouTube
This video is an explanation and demo of the withLatestFrom () operator in RxJS.In this series on RxJS we explore commonly used operators...
Read more >Have withLatestFrom wait until all sources have produced one ...
No. The added marbles would be produced exactly the way you want with only withLatestFrom. Until all sources have a value those two...
Read more >withLatestFrom - Learn RxJS
import { withLatestFrom, map } from 'rxjs/operators';. import { interval } from 'rxjs';. . //emit every 5s. const source = interval(5000);. //emit every...
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
@xtianjohns thanks for the initiative. I think we should implement all extra operators with OOP and extending the Operator type. This way we have more control over corner cases, and (important) we get to name each producer/operator with a string that will be shown in the devtools.
One thing that
withLatestFrom
as an extra could do is fire events from the main stream even before the first event from the sampler stream. The combinator function should be called with only one argument in those cases.The recommended
B.map(b => A.map(a => f(a, b))).flatten()
replacement returnsinstead of