我有这样的信息流:
def myStream[T: AS: MAT](source: Source[T, NotUsed]): Future[Seq[T]] = {
return source.runWith(Sink.seq)
}
def myMethod(colorStream: Source[Color, NotUsed]) {
val allColors = myStream(colorStream).map(_.toList)
//how can I actually extract the things from allColors
//so that I can call my method below? myOtherMethod
if I do println(allColors.map(println _)) I can print the elements fine
}
def myOtherMethod(colors: Seq[Color] = List.empty()) {
...
}
答案 0 :(得分:1)
allColors是未来。您需要访问将来要包装的内容才能访问colours:Seq [Color]。试试这个:
allColors.onComplete{
case Success(list) => myOtherMethod(list)
case Failure(err) => //handle the error
}