Android 12 Developer Preview is here! Try it out, and give us your feedback!

RxWorker

abstract class RxWorker : ListenableWorker
kotlin.Any
   ↳ androidx.work.ListenableWorker
   ↳ androidx.work.RxWorker

RxJava2 interoperability Worker implementation.

When invoked by the WorkManager, it will call @createWork() to get a Single<Result> subscribe to it.

By default, RxWorker will subscribe on the thread pool that runs WorkManager Workers. You can change this behavior by overriding getBackgroundScheduler() method.

An RxWorker is given a maximum of ten minutes to finish its execution and return a androidx.work.ListenableWorker.Result. After this time has expired, the worker will be signalled to stop.

Summary

Public constructors
<init>(@NonNull appContext: Context, @NonNull workerParams: WorkerParameters)

Public methods
abstract Single<ListenableWorker.Result!>

Override this method to define your actual work and return a Single of androidx.work.ListenableWorker.Result which will be subscribed by the WorkManager.

open Unit

Completable
setCompletableProgress(@NonNull data: Data)

Updates the progress for a RxWorker.

Single<Void!>
setProgress(@NonNull data: Data)

Updates the progress for a RxWorker.

open ListenableFuture<ListenableWorker.Result!>

Protected methods
open Scheduler

Returns the default background scheduler that RxWorker will use to subscribe.

Inherited functions

Public constructors

<init>

RxWorker(
    @NonNull appContext: Context