vertx / io.vertx.rx.java / ReadStreamSubscriber

# ReadStreamSubscriber

`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

### Constructors

<init> | `ReadStreamSubscriber(adapter: Function<R, J>)`

### Properties

BUFFER_SIZE | `static val BUFFER_SIZE: Int`

### Functions

asReadStream | `open static fun <R : Any, J : Any> asReadStream(observable: Observable<R>, adapter: Function<R, J>): ReadStream<J>`
endHandler | `open fun endHandler(handler: Handler<Void>): ReadStream<J>`
exceptionHandler | `open fun exceptionHandler(handler: Handler<Throwable>): ReadStream<J>`
handler | `open fun handler(handler: Handler<J>): ReadStream<J>`
onCompleted | `open fun onCompleted(): Unit`
onError | `open fun onError(e: Throwable): Unit`
onNext | `open fun onNext(item: R): Unit`
pause | `open fun pause(): ReadStream<J>`
resume | `open fun resume(): ReadStream<J>`