+str #19020 reduce combinator
This commit is contained in:
parent
55425e5ef3
commit
a2ab7f29e1
15 changed files with 247 additions and 37 deletions
|
|
@ -396,6 +396,22 @@ class SubSource[+Out, +Mat](delegate: scaladsl.SubFlow[Out, Mat, scaladsl.Source
|
|||
def fold[T](zero: T)(f: function.Function2[T, Out, T]): SubSource[T, Mat] =
|
||||
new SubSource(delegate.fold(zero)(f.apply))
|
||||
|
||||
/**
|
||||
* Similar to `fold` but uses first element as zero element.
|
||||
* Applies the given function towards its current and next value,
|
||||
* yielding the next current value.
|
||||
*
|
||||
* '''Emits when''' upstream completes
|
||||
*
|
||||
* '''Backpressures when''' downstream backpressures
|
||||
*
|
||||
* '''Completes when''' upstream completes
|
||||
*
|
||||
* '''Cancels when''' downstream cancels
|
||||
*/
|
||||
def reduce(f: function.Function2[Out, Out, Out @uncheckedVariance]): SubSource[Out, Mat] =
|
||||
new SubSource(delegate.reduce(f.apply))
|
||||
|
||||
/**
|
||||
* Intersperses stream with provided element, similar to how [[scala.collection.immutable.List.mkString]]
|
||||
* injects a separator between a List's elements.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue