Package-level declarations

Types

Link copied to clipboard
interface Action
Link copied to clipboard
Link copied to clipboard
abstract class Effect<A : Action> : Reaction<A> , CancellableEffect

Behavior that is performed as a reaction to an Action.

Link copied to clipboard
value class EffectId(val id: String)
Link copied to clipboard
fun interface EffectIdSource

A source that provides EffectIds for a Store. These ids are assigned to effects when they are run.

Link copied to clipboard
sealed class EffectState<out R>
Link copied to clipboard
fun interface ExceptionHandler
Link copied to clipboard
Link copied to clipboard
sealed interface FlowEffectEvent<out R>
Link copied to clipboard
sealed interface FlowEffectState

Signals active state of a FlowEffect. Does not contain the actions emitted by the flow. The reducer controls what to do with the emitted actions and how to incorporate them in the State.

Link copied to clipboard
class IntegerEffectIdSource(initalValue: Int = 1) : EffectIdSource

An EffectIdSource that generates monotonically increasing integers as ids, always incrementing by 1.

Link copied to clipboard

An EffectIdSource that iterates through a fixed list of configured EffectIds. Throws NoSuchElementException when the list has been exceeded.

Link copied to clipboard
value class OwnerId(val id: String)
Link copied to clipboard
sealed interface Reaction<out A : Action>

Describes a reaction to an Action that is different from changing the State.

Link copied to clipboard
fun interface Reducer<S : State, A : Action>

The Reducer determines what happens in response to an Action:

Link copied to clipboard
data class Reduction<S : State, A : Action>

The result of a Reducer.reduce call. Consists of:

Link copied to clipboard
interface State
Link copied to clipboard
class Store<S : State, A : Action>(reducer: Reducer<S, A>, initialState: S, coroutineDispatcher: CoroutineDispatcher = Dispatchers.Default, coroutineScopeName: String = DEFAULT_COROUTINE_SCOPE_NAME, effectIdSource: EffectIdSource = UUIDEffectIdSource(), logger: Logger = NoopLogger(), exceptionHandler: ExceptionHandler = ThrowingExceptionHandler, parentJob: Job? = null) : AutoCloseable

A construct for managing complex state safely in concurrent environments.

Link copied to clipboard

An EffectIdSource that generates random Uuids as EffectIds.

Functions

Link copied to clipboard
fun <A : Action> effect(effectId: EffectId, triggerAction: A, ownerId: OwnerId? = null, block: suspend () -> A): Effect<A>

Effect builder function.

Link copied to clipboard
fun <R> FlowEffectEvent<R>.emittedValueOrElse(orElse: () -> R): R
fun <R, T> FlowEffectEvent<R>.emittedValueOrElse(valueTransformer: (R) -> T, orElse: () -> T): T
Link copied to clipboard
fun <A : Action> flowEffect(effectId: EffectId, triggerAction: A, ownerId: OwnerId? = null, block: suspend () -> Flow<A>): FlowEffect<A>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <A : Action, R, C : A> trackedEffect(effectId: EffectId, triggerAction: A, actionWrapper: (EffectState<R>) -> C, ownerId: OwnerId? = null, block: suspend () -> R): FlowEffect<A>
Link copied to clipboard
fun <A : Action, R, C : A> trackedFlowEffect(effectId: EffectId, triggerAction: A, actionWrapper: (FlowEffectEvent<R>) -> C, ownerId: OwnerId? = null, block: suspend () -> Flow<R>): FlowEffect<A>