question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement "withLatestFrom" as an extra operator

See original GitHub issue

I’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
}
  1. Is it possible, to easly compose it from existing operators?
  2. Maybe it could be implemented as an extra?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
staltzcommented, Sep 22, 2016

@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.

2reactions
Hypnosphicommented, Aug 15, 2016

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 returns

-------2a----3b-------4d--

instead of

--1?---2a----3b-------4d--
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found