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

commonMain.com.adeo.kviewmodel.compose.Flow+State.kt Maven / Gradle / Ivy

@file:Suppress("NOTHING_TO_INLINE")

package com.adeo.kviewmodel.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.EmptyCoroutineContext

@Composable
public inline fun  StateFlow.observeAsState(context: CoroutineContext = EmptyCoroutineContext): State {
    return collectAsState(context = context)
}

@Composable
public inline fun  SharedFlow.observeAsState(context: CoroutineContext = EmptyCoroutineContext): State {
    return collectAsState(initial = null, context = context)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy