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)
}