Package-level declarations

Types

Link copied to clipboard
typealias Acceptor<Proposal, State> = (proposal: Proposal, state: State) -> State?

Function for accepting / rejecting a Proposal. If the proposal is accepted, returns the new State (which is based on the Proposal). If the proposal is rejected, returns Null.

Link copied to clipboard
annotation class BlocDSL
Link copied to clipboard
typealias BlocObserver<State> = (State) -> Unit

This is the Observer specifically for Swift

Link copied to clipboard
typealias Cancel = () -> Unit

A function used to cancel Coroutines launched with InitializerContext.launch, ThunkContext.launch or ReducerContext.launch

Link copied to clipboard
typealias Dispatcher<Action> = suspend (Action) -> Unit

Function to dispatch actions to a bloc. Dispatchers are used by Initializers and Thunks or ThunkNoActions to dispatch an action to the "next" thunk or reducer in the execution chain.

Link copied to clipboard
data class Effect<Proposal : Any, SideEffect : Any>(val proposal: Proposal?, val sideEffects: List<SideEffect>)
Link copied to clipboard
class FragmentViewBindingDelegate<T : ViewBinding>(val fragment: Fragment, val viewBindingFactory: (View) -> T) : ReadOnlyProperty<Fragment, T>
Link copied to clipboard
typealias GetState<State> = () -> State

Function that returns the current state. GetState is used by thunks to retrieve the current state of the bloc and is accessible through the ThunkContext / ThunkContextNoAction.

Link copied to clipboard

Function that is executed when the bloc is created.

Link copied to clipboard
data class InitializerContext<State, Action, Proposal>(val getState: GetState<State>, val dispatch: Dispatcher<Action>, val reduce: suspend (proposal: Proposal) -> Unit, launchBlock: Launch)

InitializerContext is used as receiver for an initializer:

Link copied to clipboard
data class JobConfig(val cancelPrevious: Boolean = false, val jobId: String = DEFAULT_JOB_ID)

The JobConfig defines how a coroutine/job is executed.

Link copied to clipboard
typealias Launch = (jobConfig: JobConfig?, block: SuspendBlock) -> Cancel

Function to launch a coroutine from one of the contexts: InitializerContext, ThunkContext or ReducerContext

Link copied to clipboard
typealias Mapper<Model, State> = (model: Model) -> State

Function to map a (Redux) model to (bloc) state.

Link copied to clipboard
class MutableStateStream<Value : Any>(initialValue: Value) : StateStream<Value> , Sink<Value>

A StateStream and a Sink at the same time.

Link copied to clipboard

Function that reduces state.

Link copied to clipboard
data class ReducerContext<State, Action>(val state: State, val action: Action, launchBlock: Launch)

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

Link copied to clipboard
data class ReducerContextNoAction<State>(val state: State, launchBlock: Launch)

ReducerContextNoAction is used as receiver for the receiver defined MVVM+ style (no action):

Link copied to clipboard

Function that reduces state.

Link copied to clipboard
typealias Selector<State, Model> = (State) -> Model

Function to select memoized sub-state from (Redux) state.

Link copied to clipboard

Function that emits a side effect.

Link copied to clipboard

Function that emits a side effect.

Link copied to clipboard
typealias SideEffectStream<Value> = Flow<Value>

A SideEffectStream is a source of asynchronous (side effect) data. It's a hot stream meant to deal with SideEffect data (compared to StateStream for State).

A SideEffectStream emits:

  • all values even duplicates

  • no initial value upon subscription (analogous PublishSubject)

A StateStream emits:

  • no duplicate values

  • an initial value upon subscription (analogous BehaviorSubject)

Link copied to clipboard
typealias SuspendBlock = suspend CoroutineScope.() -> Unit

Suspend function passed as parameter to one of the launch function calls: InitializerContext.launch, ThunkContext.launch or ReducerContext.launch

Link copied to clipboard
typealias Thunk<State, Action, A, Proposal> = suspend ThunkContext<State, Action, A, Proposal>.() -> Unit

Function that runs asynchronous code.

Link copied to clipboard
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:

Link copied to clipboard
data class ThunkContextNoAction<State, Action, Proposal>(val getState: GetState<State>, val dispatch: Dispatcher<Action>, val reduce: suspend (proposal: Proposal) -> Unit, launchBlock: Launch)

ThunkContextNoAction is used as receiver for the thunk defined MVVM+ style (no action):

Link copied to clipboard

Function that runs asynchronous code.

Functions

Link copied to clipboard

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

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

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

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

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

Link copied to clipboard
fun <State : Any, SideEffect : Any> BlocObservableOwner<State, SideEffect>.subscribe(lifecycle: Lifecycle, state: suspend (state: State) -> Unit? = null, sideEffect: suspend (sideEffect: SideEffect) -> Unit? = null)

Analogous call for BlocObservableOwner

fun <State : Any, Action : Any, SideEffect : Any, Proposal : Any> BlocOwner<State, Action, SideEffect, Proposal>.subscribe(lifecycle: Lifecycle, state: suspend (state: State) -> Unit? = null, sideEffect: suspend (sideEffect: SideEffect) -> Unit? = null)

Call from a component to observe state and side effect updates in a BlocOwner (BlocOwner in Android is typically a ViewModel, the observing component a Fragment or an Activity):

fun <State : Any, Action : Any, SideEffect : Any> Bloc<State, Action, SideEffect>.subscribe(lifecycle: Lifecycle, state: suspend (state: State) -> Unit? = null, sideEffect: suspend (sideEffect: SideEffect) -> Unit? = null)

Subscribes to the state and side effects streams of a Bloc.

Link copied to clipboard
inline fun <T : ViewBinding> Fragment.viewBinding(): FragmentViewBindingDelegate<T>