laglangyue commented on code in PR #989:
URL: https://github.com/apache/incubator-pekko/pull/989#discussion_r1460777227
##########
docs/src/main/paradox/stream/operators/Sink/forall.md:
##########
@@ -0,0 +1,34 @@
+# Sink.forall
+
+forall applies a predicate assertion to each element in the stream; it returns
true if all elements satisfy the assertion, otherwise it returns false.
+
+## Signature
+
+@apidoc[Sink.forall](Sink$) {
scala="#forall(predicate:T=>U):org.apache.pekko.stream.scaladsl.Sink[T,scala.concurrent.Future[Boolean]]"
java="#forall(org.apache.pekko.japi.function.Predicate)" }
+
+## Description
+forall, is implemented through `Fold`, applies a predicate assertion to each
element in the stream; it returns true if all elements satisfy the assertion,
otherwise it returns false.
+
+It materializes into a `Future` (in Scala) or a `CompletionStage` (in Java)
that completes with the last state when the stream has finished.
+
+This operator enables combining values into a result without relying on global
mutable state, as it passes the state along between invocations.
+
+## Example
+
+This example reads a stream of positive integers, asserts that all numbers are
greater than 0, and finally prints the assertion result.
+
+Scala
+: @@snip
[snip](/stream-tests/src/test/scala/org/apache/pekko/stream/scaladsl/SinkSpec.scala)
{ #forall }
+
+Java
+: @@snip
[snip](/stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SinkTest.java)
{ #forall }
+
+## Reactive Streams Semantics
+
+@@@div { .callout }
+
+**cancels**: never
+
+**backpressures**: when the previous predicate function invocation has not yet
completed
Review Comment:
I have tried my best to describe it again, but the theory here is not clear
yet. Can you improve it
--
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]