public class ReadStreamSubscriber<R,J> extends rx.Subscriber<R> implements ReadStream<J>
Subscriber that turns an Observable into a ReadStream.
The stream implements the pause() and resume() operation by maintaining
a buffer of BUFFER_SIZE elements between the Observable and the ReadStream.
When the subscriber is created it requests 0 elements to activate the subscriber's back-pressure.
Setting the handler initially on the ReadStream triggers a request of BUFFER_SIZE elements.
When the item buffer is half empty, new elements are requested to fill the buffer back to BUFFER_SIZE
elements.
The #endHandler(Handler is called when the Observable is completed or has failed and
no pending elements, emitted before the completion or failure, are still in the buffer, i.e the handler
is not called when the stream is paused.
| Modifier and Type | Field and Description |
|---|---|
static int |
BUFFER_SIZE |
| Constructor and Description |
|---|
ReadStreamSubscriber(Function<R,J> adapter,
Consumer<rx.Subscriber<R>> doSubscribe) |
| Modifier and Type | Method and Description |
|---|---|
static <R,J> ReadStream<J> |
asReadStream(rx.Observable<R> observable,
Function<R,J> adapter) |
ReadStream<J> |
endHandler(Handler<Void> handler) |
ReadStream<J> |
exceptionHandler(Handler<Throwable> handler) |
ReadStream<J> |
fetch(long amount) |
ReadStream<J> |
handler(Handler<J> handler) |
void |
onCompleted() |
void |
onError(Throwable e) |
void |
onNext(R item) |
ReadStream<J> |
pause() |
ReadStream<J> |
resume() |
add, isUnsubscribed, onStart, request, setProducer, unsubscribeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitpipe, pipeTo, pipeTopublic static final int BUFFER_SIZE
public static <R,J> ReadStream<J> asReadStream(rx.Observable<R> observable, Function<R,J> adapter)
public ReadStream<J> handler(Handler<J> handler)
handler in interface ReadStream<J>public ReadStream<J> pause()
pause in interface ReadStream<J>public ReadStream<J> fetch(long amount)
fetch in interface ReadStream<J>public ReadStream<J> resume()
resume in interface ReadStream<J>public ReadStream<J> endHandler(Handler<Void> handler)
endHandler in interface ReadStream<J>public ReadStream<J> exceptionHandler(Handler<Throwable> handler)
exceptionHandler in interface ReadStream<J>exceptionHandler in interface StreamBasepublic void onCompleted()
onCompleted in interface rx.Observer<R>Copyright © 2024 Eclipse. All rights reserved.