commonMain.moe.tlaster.precompose.lifecycle.LifecycleOwner.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of precompose-jvm Show documentation
Show all versions of precompose-jvm Show documentation
A third-party Jetbrains Compose library with ViewModel, LiveData and Navigation support.
package moe.tlaster.precompose.lifecycle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.compositionLocalOf
interface LifecycleOwner {
val lifecycle: Lifecycle
}
val LocalLifecycleOwner = compositionLocalOf { noLocalProvidedFor("LocalLifecycleOwner") }
/**
* Returns current composition local value for the owner.
* @throws IllegalStateException if no value was provided.
*/
val currentLocalLifecycleOwner: LifecycleOwner
@Composable
@ReadOnlyComposable
get() = LocalLifecycleOwner.current
private fun noLocalProvidedFor(name: String): Nothing {
error("CompositionLocal $name not present")
}