I am doing this:
val fileUploadRequest = OneTimeWorkRequestBuilder<FileUploadWorker>().build()
Futures.addCallback(workManager.enqueueUniqueWork(this::class.simpleName!!, ExistingWorkPolicy.KEEP, fileUploadRequest).result,
object : FutureCallback<Operation.State.SUCCESS> {
override fun onSuccess(result: Operation.State.SUCCESS?) {
Log.d(TAG, "onSuccess: ")
}
override fun onFailure(t: Throwable) {
Log.d(TAG, "onFailure: ")
}
},
executor
)
with this RxWorker code:
override fun createWork(): Single<Result> {
return Single.just(Result.failure())
}
I always end up in onSuccess(). How come?
Also: Is the Futures callback ever removed? Or does it live forever? Do I need to remove it manually during some circumstances?