open class ReadStreamSubscriber<R : Any, J : Any> : Subscriber<R>, ReadStream<J>
An RxJava 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 < 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.
Author
Julien Viet
ReadStreamSubscriber(adapter: Function<R, J>) |
static val BUFFER_SIZE: Int |
open static fun <R : Any, J : Any> asReadStream(observable: Observable<R>, adapter: Function<R, J>): ReadStream<J> |
|
open fun endHandler(handler: Handler<Void>): ReadStream<J> |
|
open fun exceptionHandler(handler: Handler<Throwable>): ReadStream<J> |
|
open fun handler(handler: Handler<J>): ReadStream<J> |
|
open fun onCompleted(): Unit |
|
open fun onError(e: Throwable): Unit |
|
open fun onNext(item: R): Unit |
|
open fun pause(): ReadStream<J> |
|
open fun resume(): ReadStream<J> |