He-Pin commented on code in PR #990:
URL: https://github.com/apache/incubator-pekko/pull/990#discussion_r1460386525


##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala:
##########
@@ -1527,6 +1527,28 @@ trait FlowOps[+Out, +Mat] {
    */
   def dropWhile(p: Out => Boolean): Repr[Out] = via(DropWhile(p))
 
+  /**
+   * Emit true and complete the stream as soon as there's an element satisfy 
the predicate.
+   * Or emit false when upstream complete and no element satisfied the 
predicate.
+   *
+   * The stream will produce true for empty stream (i.e. completes before 
signalling any elements).
+   *
+   * The stream will never complete if there's no element satisfied the 
predicate and upstream isn't completed.
+   *
+   * Adheres to the [[ActorAttributes.SupervisionStrategy]] attribute.
+   *
+   * '''Emits when''' predicate returned true or upstream completes
+   *
+   * '''Backpressures when''' downstream backpressures
+   *
+   * '''Completes when''' predicate returned true or upstream completes
+   *
+   * '''Cancels when''' predicate returned true or downstream cancels
+   */
+  def exists(p: Out => Boolean): Repr[Boolean] = map(p).takeWhile(!_, 
inclusive = true).fold(true) {

Review Comment:
   `map` and `takeWhile` can be expressed with `collectWhile`/`collectFirst`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to