Sink.seq
Collect values emitted from the stream into a collection.
Signature¶
Description¶
Collect values emitted from the stream into a collection, the collection is available through a Future
or which completes when the stream completes. Note that the collection is bounded to Int.MaxValue
, if more element are emitted the sink will cancel the stream
Example¶
Given a stream of numbers we can collect the numbers into a collection with the seq
operator
sourceval source = Source(1 to 3)
val result = source.runWith(Sink.seq[Int])
val seq = result.futureValue
seq.foreach(println)
// will print
// 1
// 2
// 3
sourceSource<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));
// 1
// 2
// 3
Reactive Streams semantics¶
cancels If too many values are collected
1.2.0-M1+35-3d489313*