1717import java .util .concurrent .CompletionStage ;
1818
1919import io .reactivex .rxjava4 .annotations .NonNull ;
20+ import io .reactivex .rxjava4 .disposables .*;
2021
2122/**
2223 * A realized stream which can then be consumed asynchronously in steps.
@@ -29,10 +30,21 @@ public interface Streamer<@NonNull T> extends AutoCloseable {
2930
3031 /**
3132 * Determine if there are more elements available from the source.
33+ * @param cancellation ability to perform cancellation on a per-virtual-pull request.
3234 * @return eventually true or false, indicating availability or termination
3335 */
3436 @ NonNull
35- CompletionStage <Boolean > next ();
37+ CompletionStage <Boolean > next (@ NonNull DisposableContainer cancellation );
38+
39+ /**
40+ * Determine if there are more elements available from the source.
41+ * Uses a default, individual {@link CompositeDisposable} to manage cancellation.
42+ * @return eventually true or false, indicating availability or termination
43+ */
44+ @ NonNull
45+ default CompletionStage <Boolean > next () {
46+ return next (new CompositeDisposable ());
47+ }
3648
3749 /**
3850 * Returns the current element if {@link #next()} yielded {@code true}.
@@ -52,7 +64,7 @@ public interface Streamer<@NonNull T> extends AutoCloseable {
5264 CompletionStage <Void > cancel ();
5365
5466 /**
55- * Make this Streamer a resource and a Closeable.
67+ * Make this Streamer a resource and a Closeable, allowing virtually blocking closing .
5668 */
5769 default void close () {
5870 cancel ().toCompletableFuture ().join ();
0 commit comments