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 Source.interleave combinator #12

Merged
merged 5 commits into from
Oct 5, 2023
Merged

Add Source.interleave combinator #12

merged 5 commits into from
Oct 5, 2023

Conversation

rucek
Copy link
Contributor

@rucek rucek commented Oct 5, 2023

No description provided.

@rucek rucek force-pushed the source-interleave branch from 698d3f4 to 151b52b Compare October 5, 2023 07:18
* scala> val res0: List[Int] = List(1, 2, 10, 20, 3, 4, 30, 40)
* }}}
*/
def interleave[U >: T](other: Source[U], segmentSize: Int = 1)(using Ox, StageCapacity): Source[U] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to consider: optionally close the resulting source if either of the source-sources are done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, good idea.

Do we also want to add some more flexibility by allowing to interleave with more than one source (like https://doc.akka.io/docs/akka/current/stream/operators/Source-or-Flow/interleaveAll.html)? Then the internal implementation of interleave would be more generic, since at the moment it is "optimized" for exactly two sources.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we could simply add an interleaveAll method :)

@adamw
Copy link
Member

adamw commented Oct 5, 2023

Looks good, exactly the kind of PR I was looking for :)

@rucek rucek marked this pull request as ready for review October 5, 2023 10:26
@adamw adamw merged commit 4c419ae into master Oct 5, 2023
@adamw adamw deleted the source-interleave branch February 21, 2024 15:21
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

Successfully merging this pull request may close these issues.

2 participants