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


##########
stream/src/main/scala/org/apache/pekko/stream/javadsl/Flow.scala:
##########
@@ -1835,6 +1835,27 @@ final class Flow[In, Out, Mat](delegate: 
scaladsl.Flow[In, Out, Mat]) extends Gr
    */
   def dropWhile(p: function.Predicate[Out]): javadsl.Flow[In, Out, Mat] = new 
Flow(delegate.dropWhile(p.test))
 
+  /**
+   * 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: function.Predicate[Out]): javadsl.Flow[In, java.lang.Boolean, 
Mat] =
+    new Flow(delegate.exists(p.test).map(Boolean.box))

Review Comment:
   if we plan to add this to `flow/source`, then `forall` operator will need to 
do the same.
   Currently, in ZIO, these method only exists on `ZSink`, but in fs2, these 
method exists on `Stream`.
   Maybe we can just have these method on Sink for now too, wdyt, @GreyPlane 
@laglangyue @pjfanning @mdedetrich 



-- 
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