An RxJava 3 fork of RxWorkManagerObservers
This library contains a set of extension functions to the WorkManager
and LiveData
allowing to observe enqueued work in a reactive manner.
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.trading-point:RxWorkManagerObservers:3.0.0'
}
WorkManager.getInstance().getWorkDataByIdSingle(request.id)
.subscribe(...)
WorkManager.getInstance().getWorkInfoByIdObservable(request.id)
.subscribe(...)
WorkManager.getInstance().getWorkDatasByTagObservable(tag = WORK_TAG, ignoreError = false)
.subscribe(...)
WorkManager.getInstance().getWorkDatasForUniqueWorkObservable(WORK_NAME)
.subscribe(...)
WorkManager.getInstance().getWorkInfoByIdLiveData(request.id)
.toWorkDataSingle()
.subscribe(...)
WorkManager.getInstance().getWorkInfoByIdLiveData(request.id)
.toWorkInfoObservable()
.subscribe(...)
WorkManager.getInstance().getWorkInfosByTagLiveData(WORK_TAG)
.toWorkDatasObservable()
.subscribe(...)
WorkManager.getInstance().getWorkInfosForUniqueWorkLiveData(WORK_NAME)
.toWorkDatasObservable()
.subscribe(...)
The Observable
returned from each function from this library have to be subscribed on the main thread (because there is LiveData.observeForever
called under the hood). The actual work, will still be executed on the background thread specified by the WorkManager
.
More about this library and the WorkManager
you can read in PaulinaSadowska's article:
How to use WorkManager with RxJava
Copyright 2021 Trading Point LTD
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.