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

commonMain.pro.respawn.flowmvi.api.StateProvider.kt Maven / Gradle / Ivy

Go to download

A Kotlin Multiplatform MVI library based on plugins that is simple, fast, powerful & flexible

There is a newer version: 3.0.0
Show newest version
package pro.respawn.flowmvi.api

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow

/**
 * An entity that exposes [states] and allows [StateConsumer]s to subscribe to them.
 * Most often accessed through a [Store] as a [Provider].
 */
public interface StateProvider {

    /**
     * A flow of  states to be handled by the subscriber.
     */
    public val states: StateFlow

    /**
     * Obtain the current state in an unsafe manner.
     * This property is not thread-safe and parallel state updates will introduce a race condition when not
     * handled properly.
     * Such race conditions arise when using multiple data streams such as [Flow]s.
     *
     * Accessing and modifying the state this way will **circumvent ALL plugins** and will not make state updates atomic.
     */
    @DelicateStoreApi
    public val state: S get() = states.value
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy