ThunkContext

data class ThunkContext<State, Action, A : Action, Proposal>(val getState: GetState<State>, val action: A, val dispatch: Dispatcher<Action>, val reduce: suspend (proposal: Proposal) -> Unit, launchBlock: Launch)

ThunkContext is used as receiver for the thunk when defining it with an action:

thunk<A: Action> {
}

// or

thunk(EnumAction) {
}

Parameters

getState

returns the current state

action

the action that triggered the thunk

dispatch

dispatches an action

reduce

reduces a proposal

launchBlock

launch a coroutine without exposing the bloc's CoroutineScope, it's internal to allow for JobConfig default values via extension functions

Constructors

Link copied to clipboard
constructor(getState: GetState<State>, action: A, dispatch: Dispatcher<Action>, reduce: suspend (proposal: Proposal) -> Unit, launchBlock: Launch)

Functions

Link copied to clipboard

Extension function for ThunkContext to launch a coroutine and run a suspend function without exposing the bloc's CoroutineScope.

Properties

Link copied to clipboard
val action: A
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val reduce: suspend (proposal: Proposal) -> Unit