Reputation: 197
Is there a better way (ie. by removing the Materializer
constraint) to implement the following method:
import akka.NotUsed
import akka.stream.Materializer
import akka.stream.scaladsl.{Keep, Sink, Source}
def assemble[A, B, C](source: Source[A, NotUsed])
(f: A => Source[B, NotUsed], g: A => Sink[B, C])
(implicit m: Materializer): Source[C, NotUsed] = {
source.map(a => f(a).toMat(g(a))(Keep.right).run())
}
?
Upvotes: 0
Views: 306
Reputation: 9023
Essentially you are after materializing a bunch of graphs and create a Source
of their materialized values.
I don't see a way of doing this without a Materializer
parameter.
In case it helps, you can write your method in a more compact fashion as
source.map(a => f(a).runWith(g(a)))
Upvotes: 2