FoldAsync op for Flow #18603

This commit is contained in:
Cédric Chantepie 2016-08-24 21:02:32 +02:00 committed by Johan Andrén
parent 9630feb6cc
commit efc87af58a
16 changed files with 519 additions and 620 deletions

View file

@ -88,8 +88,17 @@ final class Source[+Out, +Mat](override val module: Module)
* function evaluation when the input stream ends, or completed with `Failure`
* if there is a failure signaled in the stream.
*/
def runFold[U](zero: U)(f: (U, Out) U)(implicit materializer: Materializer): Future[U] =
runWith(Sink.fold(zero)(f))
def runFold[U](zero: U)(f: (U, Out) U)(implicit materializer: Materializer): Future[U] = runWith(Sink.fold(zero)(f))
/**
* Shortcut for running this `Source` with a foldAsync function.
* The given function is invoked for every received element, giving it its previous
* output (or the given `zero` value) and the element as input.
* The returned [[scala.concurrent.Future]] will be completed with value of the final
* function evaluation when the input stream ends, or completed with `Failure`
* if there is a failure signaled in the stream.
*/
def runFoldAsync[U](zero: U)(f: (U, Out) Future[U])(implicit materializer: Materializer): Future[U] = runWith(Sink.foldAsync(zero)(f))
/**
* Shortcut for running this `Source` with a reduce function.