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

flatten method for Stream[Stream[T]] #197

Closed
nimatrueway opened this issue Aug 18, 2024 · 1 comment
Closed

flatten method for Stream[Stream[T]] #197

nimatrueway opened this issue Aug 18, 2024 · 1 comment

Comments

@nimatrueway
Copy link
Contributor

nimatrueway commented Aug 18, 2024

Is there any tool of such nature for Stream, I was writing a few examples for my company to compare different Scala streaming libraries (e.g. monix Observable, fs2 Stream, ox Source, etc.) that I run into this case.

Source.fromIterable(splitRange(request.startDate, request.endDate)) // = STREAM[(Instant, Instant)]
  .mapPar(4) { case (start, end) =>
    service.fetch(start, end) // = STREAM[T]
  } // = STREAM[STREAM[T]]
  .flatten // DOES NOT EXIST 😭

I was just wondering if this is overlooked or is there any solid reason as to not include flatten in Source api?

@nimatrueway
Copy link
Contributor Author

nimatrueway commented Aug 19, 2024

I looked into how this can be implemented based on Source[T].merge, and wrote a quick draft implementation of my idea at #198

I suspect that having a select that allows a mutable list of ReceiveClause so that we can add to the clauses as the parent source generates more children sources will boost performance 🤔

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