Subject to change.
Lorraine is a work management framework for tasks.
First add the dependency to your project:
Lastest vesion: https://mvnrepository.com/artifact/io.github.dottttt.lorraine/lorraine
[versions]
lorraine = "$lastestversion"
[libraries]
lorraine = { module = "io.github.dottttt.lorraine:lorraine", version.ref = "lorraine" }
Initialize Lorraine with workers.
const val GET_WORKER = "GET_WORKER"
lorraine {
work(GET_WORKER) { GetWorker() }
...
}
Create workers by extending WorkLorraine
class GetWorker : WorkLorraine() {
override suspend fun doWork(inputData: Data?): LorraineResult {
...
return LorraineResult.success() / LorraineResult.retry() / LorraineResult.failure()
}
}
Launch your worker
Lorraine.enqueue(
uniqueId = "UNIQUE_ID",
type = ExistingLorrainePolicy.APPEND,
request = lorraineRequest {
identifier = GET_WORKER
constraints {
requiredNetwork = true
}
}
)
Report any issue on this GitHub repository.
- Koin (for dsl): https://github.com/InsertKoinIO/koin
- WorkManager (for Android): https://developer.android.com/develop/background-work/background-tasks/persistent/getting-started
- NSOperation (for iOS): https://developer.apple.com/documentation/foundation/nsoperation
Feel free to open pull request