Getting data out of a Future in Scala -
i've future[list[person]][1] , want list[person] it. how can ?
import scala.concurrent.future val futpersons : future[list[person]] = ....
there multiple ways:
futpersons.map { personlist => .... } this map returns future composed whatever return map. map execute if future completes successfully. if need handle failure can use oncomplete
futpersons.oncomplete { case success(personlist) => ... case failure(exception) => ... } or can wait future complete (this blocking):
val personlist: list[person] = await.result(futpersons, 1 minutes)
Comments
Post a Comment