Collect values emitted from the stream into a collection.
Collect values emitted from the stream into a collection, the collection is available through a
CompletionStage or which completes when the stream completes. Note that the collection is bounded to
Integer.MAX_VALUE, if more element are emitted the sink will cancel the stream
Given a stream of numbers we can collect the numbers into a collection with the
val source = Source(1 to 3)
val result = source.runWith(Sink.seq[Int])
val seq = result.futureValue
// will print
Source<Integer, NotUsed> ints = Source.from(Arrays.asList(1, 2, 3));
CompletionStage<List<Integer>> result = ints.runWith(Sink.seq(), system);
result.thenAccept(list -> list.forEach(System.out::println));
Reactive Streams semantics
cancels If too many values are collected
Found an error in this documentation? The source code for this page can be found here
Please feel free to edit and contribute a pull request.