commonMain.com.eygraber.vice.sources.FlowSource.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vice-sources-jvm Show documentation
Show all versions of vice-sources-jvm Show documentation
Implementations of ViceSource for use with vice-core
The newest version!
package com.eygraber.vice.sources
import androidx.compose.runtime.Composable
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.eygraber.vice.ViceSource
import kotlinx.coroutines.flow.Flow
public abstract class FlowSource : ViceSource {
protected abstract val flow: Flow
protected abstract val initial: T
@Composable
final override fun currentState(): T = flow.collectAsStateWithLifecycle(initial).value
}