commonMain.com.episode6.redux.api.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Core implementation of Redux StoreFlow
The newest version!
package com.episode6.redux
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
/**
* Represents a redux store backed by a [kotlinx.coroutines.flow.StateFlow]
*/
interface StoreFlow : Flow {
val initialState: State
val state: State
fun dispatch(action: Action)
}
/**
* Identifies a redux action that can be dispatched/interpreted by a [StoreFlow]
*/
interface Action
/**
* Function that dispatches an action to a [StoreFlow]
*/
typealias Dispatch = (Action) -> Unit
/**
* Reduces a state + action to a new state
*/
typealias Reducer = State.(Action) -> State
/**
* Gets the chance to interfere with a [StoreFlow]'s dispatch of actions
*/
fun interface Middleware {
fun CoroutineScope.interfere(store: StoreFlow, next: Dispatch): Dispatch
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy