diff --git a/README.md b/README.md index a27b6f7..9bf8b15 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,42 @@ lorraine = "0.0.1" lorraine = { module = "io.github.dottttt.lorraine:lorraine", version.ref = "lorraine" } ``` -## Start using Lorraine +## Using it +#### Initialization +```kotlin +const val GET_WORKER = "GET_WORKER" + +lorraine { + work(GET_WORKER) { GetWorker() } + ... +} +``` + +```kotlin +class GetWorker : WorkLorraine() { + + override suspend fun doWork(inputData: Data?): LorraineResult { + ... + return LorraineResult.success() / LorraineResult.retry() / LorraineResult.failure() + } + +} +``` + +```kotlin +Lorraine.enqueue( + uniqueId = "UNIQUE_ID", + type = ExistingLorrainePolicy.APPEND, + request = lorraineRequest { + identifier = GET_WORKER + constraints { + requiredNetwork = true + } + } +) +``` ## Principles @@ -32,6 +65,8 @@ Report any issue on this GitHub repository. ## Inspirations +- Koin: https://github.com/InsertKoinIO/koin + - Android: WorkManager - iOS: NSOperation