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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -