Reputation: 5619
I have the following code:
val f0: Future[Seq[Seq[Int]]] = processPrerequisitesDTO.getProcessPrerequisiteIdsByProcessTemplateId(processTemplateId).flatMap(pres =>
Future.sequence(
pres.map(pre =>
processPrerequisitesDTO.getProcessPrerequisiteProcessTemplateIdsByProcessTemplateId(pre)
))
)
How can I flat one Seq? The Future should be kept.
Thanks.
Upvotes: 0
Views: 75
Reputation: 19517
You could call map
on the Future
and flatten the Seq[Seq[Int]]
:
val flattened = f0.map(_.flatten)
// Future[Seq[Int]]
Upvotes: 1