Skip to content

Instantly share code, notes, and snippets.

@macalinao
Created November 12, 2016 07:16
Show Gist options
  • Save macalinao/119b2aff3a6116aa975bc49529d9a215 to your computer and use it in GitHub Desktop.
Save macalinao/119b2aff3a6116aa975bc49529d9a215 to your computer and use it in GitHub Desktop.
def sequenceMap[S, T](map: Map[S, Future[T]])(implicit ec: ExecutionContext): Future[Map[S, T]] = {
Future.sequence(map.map { case (k, fut) =>
fut.map(v => (k, v))
}).map(_.toMap)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment