You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
forall applies a predicate function to assert each element received, it returns true if all elements satisfy the assertion, otherwise it returns false.
13
+
14
+
It materializes into a `Future` (in Scala) or a `CompletionStage` (in Java) that completes with the last state when the stream has finished.
15
+
16
+
Notes that if source is empty, it will return true
17
+
18
+
A `Sink` that will test the given predicate `p` for every received element and
19
+
20
+
- completes and returns @scala[`Future`]@java[`CompletionStage`] of `true` if the predicate is true for all elements;
21
+
- completes and returns @scala[`Future`]@java[`CompletionStage`] of `true` if the stream is empty (i.e. completes before signalling any elements);
22
+
- completes and returns @scala[`Future`]@java[`CompletionStage`] of `false` if the predicate is false for any element.
23
+
24
+
The materialized value @scala[`Future`]@java[`CompletionStage`] will be completed with the value `true` or `false`
25
+
when the input stream ends, or completed with `Failure` if there is a failure signaled in the stream.
26
+
27
+
## Example
28
+
29
+
This example tests all elements in the stream is `<=` 100.
Copy file name to clipboardExpand all lines: docs/src/main/paradox/stream/operators/index.md
+2
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,7 @@ These built-in sinks are available from @scala[`org.apache.pekko.stream.scaladsl
62
62
|Sink|<aname="completionstagesink"></a>@ref[completionStageSink](Sink/completionStageSink.md)|Streams the elements to the given future sink once it successfully completes. |
63
63
|Sink|<aname="fold"></a>@ref[fold](Sink/fold.md)|Fold over emitted elements with a function, where each invocation will get the new element and the result from the previous fold invocation.|
64
64
|Sink|<aname="foldwhile"></a>@ref[foldWhile](Sink/foldWhile.md)|Fold over emitted elements with a function, where each invocation will get the new element and the result from the previous fold invocation.|
65
+
|Sink|<aname="forall"></a>@ref[forall](Sink/forall.md)|A `Sink` that will test the given predicate `p` for every received element and completes with the result.|
65
66
|Sink|<aname="foreach"></a>@ref[foreach](Sink/foreach.md)|Invoke a given procedure for each element received.|
66
67
|Sink|<aname="foreachasync"></a>@ref[foreachAsync](Sink/foreachAsync.md)|Invoke a given procedure asynchronously for each element received.|
67
68
|Sink|<aname="foreachparallel"></a>@ref[foreachParallel](Sink/foreachParallel.md)|Like `foreach` but allows up to `parallellism` procedure calls to happen in parallel.|
@@ -459,6 +460,7 @@ For more background see the @ref[Error Handling in Streams](../stream-error.md)
0 commit comments