Added a flag on takeWhile to allow it to include the final element, #21330
This commit is contained in:
parent
7eb660b497
commit
a28d2c579f
9 changed files with 120 additions and 30 deletions
|
|
@ -578,9 +578,9 @@ class SubSource[+Out, +Mat](delegate: scaladsl.SubFlow[Out, Mat, scaladsl.Source
|
|||
|
||||
/**
|
||||
* Terminate processing (and cancel the upstream publisher) after predicate
|
||||
* returns false for the first time. Due to input buffering some elements may have been
|
||||
* requested from upstream publishers that will then not be processed downstream
|
||||
* of this step.
|
||||
* returns false for the first time,
|
||||
* Due to input buffering some elements may have been requested from upstream publishers
|
||||
* that will then not be processed downstream of this step.
|
||||
*
|
||||
* The stream will be completed without producing any elements if predicate is false for
|
||||
* the first stream element.
|
||||
|
|
@ -589,12 +589,31 @@ class SubSource[+Out, +Mat](delegate: scaladsl.SubFlow[Out, Mat, scaladsl.Source
|
|||
*
|
||||
* '''Backpressures when''' downstream backpressures
|
||||
*
|
||||
* '''Completes when''' predicate returned false or upstream completes
|
||||
* '''Completes when''' predicate returned false (or 1 after predicate returns false if `inclusive` or upstream completes
|
||||
*
|
||||
* '''Cancels when''' predicate returned false or downstream cancels
|
||||
*/
|
||||
def takeWhile(p: function.Predicate[Out]): SubSource[Out, Mat] =
|
||||
new SubSource(delegate.takeWhile(p.test))
|
||||
def takeWhile(p: function.Predicate[Out]): SubSource[Out, Mat] = takeWhile(p, false)
|
||||
|
||||
/**
|
||||
* Terminate processing (and cancel the upstream publisher) after predicate
|
||||
* returns false for the first time, including the first failed element iff inclusive is true
|
||||
* Due to input buffering some elements may have been requested from upstream publishers
|
||||
* that will then not be processed downstream of this step.
|
||||
*
|
||||
* The stream will be completed without producing any elements if predicate is false for
|
||||
* the first stream element.
|
||||
*
|
||||
* '''Emits when''' the predicate is true
|
||||
*
|
||||
* '''Backpressures when''' downstream backpressures
|
||||
*
|
||||
* '''Completes when''' predicate returned false (or 1 after predicate returns false if `inclusive` or upstream completes
|
||||
*
|
||||
* '''Cancels when''' predicate returned false or downstream cancels
|
||||
*/
|
||||
def takeWhile(p: function.Predicate[Out], inclusive: Boolean): SubSource[Out, Mat] =
|
||||
new SubSource(delegate.takeWhile(p.test, inclusive))
|
||||
|
||||
/**
|
||||
* Discard elements at the beginning of the stream while predicate is true.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue