All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.moe.tlaster.precompose.lifecycle.LifecycleOwner.kt Maven / Gradle / Ivy

Go to download

A third-party Jetbrains Compose library with ViewModel, LiveData and Navigation support.

There is a newer version: 1.7.0-alpha03
Show newest version
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")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy