Skip to content

//workflow/com.squareup.workflow1.rx2/asWorker

asWorker

[jvm]
Content
inline fun <T : Any> ObservableT?>.asWorker(): Worker<T>
More info

Creates a Worker from this Observable.

The Observable will be subscribed to when the Worker is started, and disposed 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.

[jvm]
Content
inline fun <T : Any> PublisherT?>.asWorker(): Worker<T>
More info

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.

[jvm]
Content
inline fun <T : Any> MaybeT?>.asWorker(): Worker<T>
More info

Creates a Worker from this Maybe.

The Maybe will be subscribed to when the Worker is started, and disposed 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.

[jvm]
Content
inline fun <T : Any> SingleT?>.asWorker(): Worker<T>
More info

Creates a Worker from this Single.

The Single will be subscribed to when the Worker is started, and disposed 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.

[jvm]
Content
fun Completable.asWorker(): Worker<Nothing>
More info

Creates a Worker from this Completable.

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

The key is required for this operator because there is no type information available to distinguish workers.

TODO: https://github.com/square/workflow-kotlin/issues/526 once this is removed.