The case of Success(listInt) => I want to return the listInt and I am not able to figure out how to do that.
The best practice is that you don’t return the value. Instead you just pass the future (or a version transformed with map
, flatMap
, etc.) to everyone who needs this value and they can add their own onComplete
.
If you really need to return it (e.g. when implementing a legacy method), then the only thing you can do is to block (e.g. with Await.result
) and you need to decide how long to await.