Skip to content

Commit

Permalink
chore: Add since 1.1.0 for foldWhile operator (#1335)
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Pin authored May 21, 2024
1 parent 5d23adb commit 1e9a051
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,8 @@ final class Flow[In, Out, Mat](delegate: scaladsl.Flow[In, Out, Mat]) extends Gr
* '''Cancels when''' downstream cancels
*
* See also [[FlowOps.fold]]
*
* @since 1.1.0
*/
def foldWhile[T](zero: T, p: function.Predicate[T], f: function.Function2[T, Out, T]): javadsl.Flow[In, T, Mat] =
new Flow(delegate.foldWhile(zero)(p.test)(f.apply))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ object Sink {
* The returned [[java.util.concurrent.CompletionStage]] will be completed with value of the final
* function evaluation when the input stream ends, predicate `p` returns false, or completed with `Failure`
* if there is a failure is signaled in the stream.
*
* @since 1.1.0
*/
def foldWhile[U, In](
zero: U, p: function.Predicate[U], f: function.Function2[U, In, U]): javadsl.Sink[In, CompletionStage[U]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,8 @@ class SubFlow[In, Out, Mat](
* '''Cancels when''' downstream cancels
*
* See also [[FlowOps.fold]]
*
* @since 1.1.0
*/
def foldWhile[T](zero: T, p: function.Predicate[T], f: function.Function2[T, Out, T]): SubFlow[In, T, Mat] =
new SubFlow(delegate.foldWhile(zero)(p.test)(f.apply))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,8 @@ trait FlowOps[+Out, +Mat] {
* '''Cancels when''' downstream cancels
*
* See also [[FlowOps.fold]]
*
* @since 1.1.0
*/
def foldWhile[T](zero: T)(p: T => Boolean)(f: (T, Out) => T): Repr[T] = via(
Fold[Out, T](zero, p, f).withAttributes(DefaultAttributes.foldWhile))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ object Sink {
* if there is a failure signaled in the stream.
*
* @see [[#fold]]
*
* @since 1.1.0
*/
def foldWhile[U, T](zero: U)(p: U => Boolean)(f: (U, T) => U): Sink[T, Future[U]] =
Flow[T].foldWhile(zero)(p)(f).toMat(Sink.head)(Keep.right).named("foldWhileSink")
Expand Down

0 comments on commit 1e9a051

Please sign in to comment.