Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 将接收器物化值收集为源_Scala_Akka Stream - Fatal编程技术网

Scala 将接收器物化值收集为源

Scala 将接收器物化值收集为源,scala,akka-stream,Scala,Akka Stream,是否有更好的方法(即通过删除物化器约束)来实现以下方法: 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[

是否有更好的方法(即通过删除
物化器
约束)来实现以下方法:

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())
}

基本上,您是在对一组图形进行物化之后,创建其物化值的源代码。 如果没有
物化器
参数,我看不到实现这一点的方法

如果有帮助的话,您可以用更简洁的方式编写方法,如下所示

source.map(a => f(a).runWith(g(a)))

本质上,您是在具体化一组图形之后,创建其具体化值的
源代码。
如果没有
物化器
参数,我看不到实现这一点的方法

如果有帮助的话,您可以用更简洁的方式编写方法,如下所示

source.map(a => f(a).runWith(g(a)))