Open VillePakarinen opened 5 years ago
Hello,
I tested out the library I noticed one issue which might need some explaining
By the spec of WorkInfo.State: WorkInfo.State - FAILED Used to indicate that the WorkRequest has completed in a failure state.
I'm not getting this State Failed out of the worker by listening to it with
WorkManager.getInstance().getWorkInfoByIdObservable(workRequest.id)
Dummy worker class below
class UpdateWorker(appContext: Context, params: WorkerParameters) : RxWorker(appContext, params) { . . . override fun createWork(): Single<Result> { val inputValue = inputData.getString(KEY_ID) ?: "" return locaRepository.getById(inputValue) .flatMap { object -> remoteRepository.update(object) } .doOnError { error -> Timber.e(error) } .toSingleDefault(Result.success()) .onErrorReturnItem(Result.failure()) } }
When the API request fails onErrorReturnItem(Result.failure()) is getting called. However
Function throws an error in the stream. Now what I would expect to happen is to receive Observable where WorkInfo.State == Failed.
Is this expected behaviour or could you add ignore error flag here as well ?
I agree, it should also apply to getWorkDataByIdSingle
getWorkDataByIdSingle
Hello,
I tested out the library I noticed one issue which might need some explaining
By the spec of WorkInfo.State: WorkInfo.State - FAILED Used to indicate that the WorkRequest has completed in a failure state.
I'm not getting this State Failed out of the worker by listening to it with
Dummy worker class below
When the API request fails onErrorReturnItem(Result.failure()) is getting called. However
Function throws an error in the stream. Now what I would expect to happen is to receive Observable where WorkInfo.State == Failed.
Is this expected behaviour or could you add ignore error flag here as well ?