workflow-rx2 / com.squareup.workflow.rx2 / org.reactivestreams.Publisher / asWorker

asWorker

fun <reified T : Any> Publisher<out T?>.asWorker(): Worker<T>

Creates a Worker from this Publisher (Flowable is a Publisher).

The Publisher will be subscribed to when the Worker is started, and cancelled when it is cancelled.

RxJava doesn't allow nulls, but it can't express that in its types. The receiver type parameter is nullable so that the resulting Worker is non-nullable instead of having platform nullability.