I'm trying to await on a funky structure like this: Future[List[Future[List[Object]]]]. Await only gets rid of the outer most Future, is there a clean way of trimming this down to a simple List[Object]?
Using Future.sequence:
val original: Future[List[Future[List[Object]]]] = // ...
val futureList =
original.flatMap(l => Future.sequence(l)) // Future[List[List[Object]]]
.map(_.flatten) // Future[List[Object]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With