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

Add switch/switchMap #114

Open
nadavwr opened this issue Sep 26, 2017 · 3 comments
Open

Add switch/switchMap #114

nadavwr opened this issue Sep 26, 2017 · 3 comments

Comments

@nadavwr
Copy link

nadavwr commented Sep 26, 2017

the switch and switchMap operators, as described in Rx (and also implemented in Monix), are very useful.

For anyone not familiar with it, switch operates over a stream of streams, always emitting from the latest stream, discarding older streams left behind.

See here for a quick standalone implementation and example.

@johanandren
Copy link
Member

Sounds interesting, I like the name latest better than switch, with Akka Streams terminology it should maybe even be flatMapLatest (flatMapConcatLatest is maybe a bit much of a mouthful).

I think it may even be useful enough that it should be a part of Akka Streams core, and implemented as a custom stage rather than composed. WDYT?

@nadavwr
Copy link
Author

nadavwr commented Oct 6, 2017

@johanandren Sorry for the late response—Google Inbox has been playing tricks on me again.

I agree this would be sufficiently useful to justify including in the core library—I chose to implement it partly because it is a "core" Rx combinator (and partly to see if I can get anywhere using non-trivial composition over the flow DSL, where Monix and FS2 have a small advantage due to abundance of combinators).

If you think this issue should be migrated to the core library, I'd be happy to reimplement and contribute it as a custom stage. Should I open an issue there?

Naming: latest is a very reasonable alternative name for switch—Rxrb uses latest, and both RxPY and RxSwift use switch_latest and switchLatest respectively. Regarding switchMap, I agree thatflatMapLatest is sufficiently clear—the word "latest" already precludes merging in any meaningful sense, so specifying the concat suffix would be redundant.

@johanandren
Copy link
Member

Yeah, please open a ticket in core Akka and give it a try, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants