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())
}
?
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 aMaterializer
parameter.In case it helps, you can write your method in a more compact fashion as