Question

What is a standard way to convert Enumerator to Future[List] in Play Scala framework?

Was it helpful?

Solution

You could use method run with parameter of type Iteratee[E, List[E]] to get Future[List[E]].

There is method getChunks, that creates Iteratee[E, List[E]]:

myEnumerator run Iteratee.getChunks

You could use Iteratee.fold to create such Iteratee manually. In case you want to preserve elements order you could use reverse on List.

myEnumerator run Iteratee.fold(List.empty[E]){ (l, e) => e :: l } map { _.reverse }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top