asWorker

inline fun <T : Any> Observable<out T?>.asWorker(): Worker<T>(source)

Creates a Worker from this Observable.

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

Note that a Worker actually operates on a kotlinx.coroutines.flow. This means that your Observable will first be adapted to a flow. To do this a communication structure is used that will mean that the flow will process the items produced by the Observable asynchronously.

Note that this Observable is transformed to a backpressure aware Flowable using the BUFFER strategy before being transformed to a flow, which means that buffering will happen in the Flowable before being passed over to the flow if it is experiencing backpressure.

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.


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

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.

Note that a Worker actually operates on a kotlinx.coroutines.flow. This means that your Publisher will first be mapped to a flow. To do this a communication structure is used that will mean that the flow will process the items produced by the Publisher asynchronously.

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.


inline fun <T : Any> Maybe<out T?>.asWorker(): Worker<T>(source)

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.


inline fun <T : Any> Single<out T?>.asWorker(): Worker<T>(source)

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.


fun Completable.asWorker(): Worker<Nothing>(source)

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.