carpenter carpenter - 1 year ago 95
Scala Question

Complex future unwraping

I know I can unwrap

Future[Future[Seq]] => Future[Seq]

With flatMap function

But how do I get following mapping?

Future[Seq[Future[Seq]]] => Future[Seq[Seq]]

Answer Source

Future.sequence will change a Seq[Future[...]] to a Future[Seq[...]]

So, something like this: obj.flatMap(x => Future.sequence(x)) perhaps?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download