dispatch-android-lifecycle
CoroutineScope functionality linked with an Android Lifecycle.
Contents
#types
#member-functions
#extension-functions
#minimum-gradle-config
Types
DispatchLifecycleScope | MainCoroutineScope with a Lifecycle, capable of automatically cancelling and restarting coroutines along with that lifecycle. |
MinimumStatePolicy | Defines the behavior of a Lifecycle-aware Job when it passes below its minimum Lifecycle.State |
Member functions
launchOnCreate | Creates a coroutine tied to a Lifecycle which will automatically enact a MinimumStatePolicy upon dropping below Lifecycle.State.CREATED |
launchOnStart | Creates a coroutine tied to a Lifecycle which will automatically enact a MinimumStatePolicy upon dropping below Lifecycle.State.STARTED |
launchOnResume | Creates a coroutine tied to a Lifecycle which will automatically enact a MinimumStatePolicy upon dropping below Lifecycle.State.RESUMED |
Extension functions
LifecycleOwner extension suspending functions:
onNextCreate | Executes code one time upon reaching a state of Lifecycle.State.CREATED |
onNextStart | Executes code one time upon reaching a state of Lifecycle.State.STARTED |
onNextResume | Executes code one time upon reaching a state of Lifecycle.State.RESUMED |
Lifecycle extension suspending functions:
onNextCreate | Executes code one time upon reaching a state of Lifecycle.State.CREATED |
onNextStart | Executes code one time upon reaching a state of Lifecycle.State.STARTED |
onNextResume | Executes code one time upon reaching a state of Lifecycle.State.RESUMED |
Minimum Gradle Config
Add to your module's build.gradle.kts
:
repositories {
mavenCentral()
}
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0")
implementation(platform("com.rickbusarow.dispatch:dispatch-bom:1.0.0-beta10"))
implementation("com.rickbusarow.dispatch:dispatch-android-lifecycle")
implementation("androidx.lifecycle:lifecycle-common:2.3.1")
}
Content copied to clipboard