ReactiveX / ReactiveX/RxPY

concat_map implementation or equivalent?

Open
#581 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

PR welcome
Dominant language
Python
Stars
5k
Forks
365
Avg merge
3d 14h
Merged PRs (30d)
4

Description

Coming from RxJS it was really convenient having the concatMap operator to have a pipeline of dynamic observables that wait for the previous to complete. I noticed that RxPY does not have an obvious equivalent (closest is flat_map but I can't have interleaving).

From what relevant docs/issues I could find, it seems that the following would achieve the same functionality but feels dirty. The of(...)'s are a stand-in for some code that would dynamically generate a new observable depending on the result from the previous.

of(1).pipe(
  map(lambda x: of(x + 1)),    # Dynamically generate observable
  merge(max_concurrent=1),     # Merge and wait to finish
  map(lambda x: of(x + 1)),    # Dynamically generate observable
  merge(max_concurrent=1)      # Merge and wait to finish
)

Is there a better way to achieve this currently (or in general a more "reactive" way)?
Is there any plan to implement a concat_map operator/alias for this functionality?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing flat_map and merge(max_concurrent=1) operators to understand how RxPY currently handles dynamically generated observables. Determine whether concat_map or an equivalent is appropriate, then verify that the chosen approach preserves sequential completion without interleaving.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.