Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: add a switchScan operator #2931

Closed
lestathc opened this issue Oct 10, 2017 · 7 comments · Fixed by #4442
Closed

Proposal: add a switchScan operator #2931

lestathc opened this issue Oct 10, 2017 · 7 comments · Fixed by #4442
Labels
feature PRs and issues for features

Comments

@lestathc
Copy link

It will be similar as the mergeScan but instead of merging all events of inner observables, if the outer source emitted a new event, it switch to the recently accumulated inner observable.

@kwonoj
Copy link
Member

kwonoj commented Oct 10, 2017

while it is not concluded yet, we're discussing of plan for mergeScan itself (#2737) and for now, we recommend to create operator as user-level first instead of direct addition into core lib. (https://github.com/ReactiveX/rxjs/blob/master/doc/operator-creation.md#diy-custom-operators-for-end-users).

@kwonoj kwonoj closed this as completed Oct 10, 2017
@kylecordes
Copy link

I have stumbled across a situation where a switchScan() would be perfect; implementing it myself does not sound like all that much fun.

@bradleyayers
Copy link

@kylecordes is your scenario solved by just passing concurrency=1?

@kylecordes
Copy link

@bradleyayers I'm not sure - I ended up solving the problem I was having a completely different way, with a group operation plus a switch map.

@benlesh
Copy link
Member

benlesh commented Feb 2, 2018

This just came up at Google... I'm going to reopen it.

Here's a minimal implementation in JS: http://jsbin.com/kiyoyir/3/edit?js,console

@benlesh benlesh reopened this Feb 2, 2018
@benlesh benlesh added feature PRs and issues for features type: discussion labels Feb 2, 2018
@fljot
Copy link
Contributor

fljot commented Jan 10, 2019

Here's a minimal implementation in JS: http://jsbin.com/kiyoyir/3/edit?js,console

@benlesh I think you forgot of disposal of outer subscription in that demo.

@cartant
Copy link
Collaborator

cartant commented Jan 28, 2019

Closing this in favour of #4442 - which has an associated PR and has been discussed in a core-team meeting.

@cartant cartant closed this as completed Jan 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 27, 2019
martinsik added a commit to martinsik/rxjs that referenced this issue Apr 8, 2020
benlesh pushed a commit to martinsik/rxjs that referenced this issue Oct 2, 2020
benlesh added a commit that referenced this issue Oct 5, 2020
* feat(switchScan): add switchScan operator

* refactor(switchScan): Make switchScan behavior more close to `scan()`

Closes #2931

* docs(switchScan): add link switchScan marble diagram into its docblock

* test(switchScan): revert running only switchScan spec

* fix(switchScan): fix overriding the same seed for multiple observers

* docs(switchScan): fix typo

* refactor(switchScan): make seed mandatory as in mergeScan

* fix(switchScan): fix typings for union types, remove duplicate dts test

* test(switchScan): fix types after rebase to master

* refactor(switchScan): use `operate` and `switchMap`.

* chore: update golden files

* chore: address comments

Co-authored-by: Ben Lesh <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature PRs and issues for features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants