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.

Remove mergeScan or provide better documentation for it

See original GitHub issue

I have a problem with mergeScan, namely, I can’t think of a single situation in which it’d be needed. The categories I see of problems almost needing mergeScan are:

  • Internal state is needed, but an inner observable is unnecessary (just use scan). The example in the docs is in this category
  • There is some operation (probably async) that requires an inner observable, but no internal state is needed (just use mergeMap). For instance, successive async calls.
  • There is an operation that requires both an async inner observable and internal state BUT is vulnerable to race conditions. In this case, mergeScan falls flat on its face, as the accumulator passed in could be stale by the time the inner observable returns. In this case, it’s better to just For example, see this (entirely contrived) example where I sum the weight of the first 10 Pokémon: http://jsbin.com/qosiwenaqi/edit?js,console

In short, I don’t see a use for mergeScan that isn’t better served by another operator and worse, it can cause unintended race conditions.

So, as a “What do we do about this issue”, I’d like either:

  • Remove the mergeScan operator from RxJS v5

or

  • Clarify intended uses of mergeScan in the docs so silly folks don’t open elaborate issues demanding its removal

(Both @robwormald and @rgbkrk have discussed this with me in various Slacks so I’m cc’ing them here)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:16 (12 by maintainers)

github_iconTop GitHub Comments

3reactions
ghetolaycommented, Jul 26, 2017

Just so you know I’m using mergeScan to do progressive image display. I download and decode the image by chunk so I need the last chunk to compute the next and all this is done async using web worker.

But in fact I’m using concatScan because I set concurrent parameter to 1 that’s why I’m not facing the race condition problem enounced.

2reactions
gilesbradshawcommented, Jan 3, 2018

Please don’t get rid of it very useful as a concatScan with concurrency = 1

Read more comments on GitHub >

github_iconTop Results From Across the Web

RxJS: Is there an operator works as mergeScan but just ...
I think you can just use the 'concurrent' argument on mergeScan. ... have 1. docs: https://rxjs-dev.firebaseapp.com/api/operators/mergeScan.
Read more >
mergeScan - RxJS
The first parameter of the mergeScan is an accumulator function which is being called every time the source Observable emits a value.
Read more >
Observable | RxJS API Document - ReactiveX
Combines multiple Observables to create an Observable whose values are calculated from the values, in order, of each of its input Observables.
Read more >
Remove docs.deleted - Elasticsearch - Discuss the Elastic Stack
Hi guys, good afternoon. So, I've been trying to remove the docs deleted for some index, but I didn't have success. Could you...
Read more >
Understanding and Controlling Database Merges
A database consists of one or more forests, and each forest consists of one or ... If you feel you need to disable...
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