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

commonMain.com.freeletics.khonshu.statemachine.StateMachine.kt Maven / Gradle / Ivy

package com.freeletics.khonshu.statemachine

import kotlinx.coroutines.flow.Flow

/**
 * A state machine that emits [State] objects through the [Flow] returned by [state]. The state
 * can be mutated through actions passed to [dispatch].
 */
public interface StateMachine {
    /**
     * A [Flow] that emits the current state as well as all changes to the state.
     */
    public val state: Flow

    /**
     * An an [Action] to the [StateMachine]. The implementation can mutate the [State] based on
     * these actions or trigger side effects.
     */
    public suspend fun dispatch(action: Action)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy