fromJavaStream
Stream the values from a Java 8 Stream
, requesting the next value when there is demand.
Signature¶
StreamConverters.fromJavaStream
Description¶
Stream the values from a Java 8 Stream
, requesting the next value when there is demand. The iterator will be created anew for each materialization, which is the reason the method
takes a function
rather than an Stream
directly.
You can use Source.async
to create asynchronous boundaries between synchronous java stream and the rest of flow.
Example¶
sourceSource.fromJavaStream(() => IntStream.rangeClosed(1, 3)).runForeach(println)
// could print
// 1
// 2
// 3
sourceSource.fromJavaStream(() -> IntStream.rangeClosed(1, 3))
.runForeach(System.out::println, system);
// could print
// 1
// 2
// 3
Reactive Streams semantics¶
emits the next value returned from the iterator
completes when the iterator reaches its end
1.1.3