Add scanAsync to Akka Streams, similar to scan but taking a Future (#21553)
* Add comprehensive tests * Add documentation * Damn comma after rebase * Add documentation for foldAsync and scanAsync * Rename aggreator and aggreating to current * Remove out availability check * Revert removing out and some refactors * Formatting documentation * Use after instead of Promise in test * Use package reference to after and some refactoring
This commit is contained in:
parent
60bea26171
commit
c3abde60d5
10 changed files with 458 additions and 4 deletions
|
|
@ -761,9 +761,37 @@ trait FlowOps[+Out, +Mat] {
|
|||
* '''Completes when''' upstream completes
|
||||
*
|
||||
* '''Cancels when''' downstream cancels
|
||||
*
|
||||
* See also [[FlowOps.scanAsync]]
|
||||
*/
|
||||
def scan[T](zero: T)(f: (T, Out) ⇒ T): Repr[T] = via(Scan(zero, f))
|
||||
|
||||
/**
|
||||
* Similar to `scan` but with a asynchronous function,
|
||||
* emits its current value which starts at `zero` and then
|
||||
* applies the current and next value to the given function `f`,
|
||||
* emitting a `Future` that resolves to the next current value.
|
||||
*
|
||||
* If the function `f` throws an exception and the supervision decision is
|
||||
* [[akka.stream.Supervision.Restart]] current value starts at `zero` again
|
||||
* the stream will continue.
|
||||
*
|
||||
* If the function `f` throws an exception and the supervision decision is
|
||||
* [[akka.stream.Supervision.Resume]] current value starts at the previous
|
||||
* current value, or zero when it doesn't have one, and the stream will continue.
|
||||
*
|
||||
* '''Emits when''' the future returned by f` completes
|
||||
*
|
||||
* '''Backpressures when''' downstream backpressures
|
||||
*
|
||||
* '''Completes when''' upstream completes and the last future returned by `f` completes
|
||||
*
|
||||
* '''Cancels when''' downstream cancels
|
||||
*
|
||||
* See also [[FlowOps.scan]]
|
||||
*/
|
||||
def scanAsync[T](zero: T)(f: (T, Out) ⇒ Future[T]): Repr[T] = via(ScanAsync(zero, f))
|
||||
|
||||
/**
|
||||
* Similar to `scan` but only emits its result when the upstream completes,
|
||||
* after which it also completes. Applies the given function towards its current and next value,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue