FoldAsync op for Flow #18603
This commit is contained in:
parent
9630feb6cc
commit
efc87af58a
16 changed files with 519 additions and 620 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue