BlocOwner
A class is a BlocOwner if it holds and exposes a Bloc.
Using extension functions this interface allows the use of the MVVM+ syntax for defining thunk { }, sideEffect { } and reduce { } / reduceAnd { }, e.g.:
fun onClicked(item: Item) = sideEffect {
ItemList.OpenItem(list)
}
If BlocOwner isn't implemented (e.g. because the Bloc shouldn't be visible outside the class), the syntax is:
fun onClicked(item: Item) = bloc.sideEffect {
ItemList.OpenItem(list)
}
If a component is a BlocOwner it doesn't have to implement BlocObservableOwner since a BlocOwner can also be observed (it has an observable Bloc) and every extension functions for BlocObservableOwner is also implemented for BlocOwner.
Functions
Submit a Reducer without side effects to a BlocOwner/Bloc to be run. The reducer will receive the state but no action (since it was triggered "manually", not by sending an action to the Bloc).
Submit a Reducer with side effects to a BlocOwner/Bloc to be run. The reducer will receive the state but no action (since it was triggered "manually", not by sending an action to the Bloc).
Submit a SideEffect to a BlocOwner/Bloc to be emitted. The side effect will receive the state but no action (since it was triggered "manually", not by sending an action to the Bloc).
Same as above for a BlocOwner
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):
Submit a Thunk to a BlocOwner/Bloc to be run. The thunk will receive the dispatch and the getState function but no action (since it was triggered "manually", not by sending an action to the Bloc). The dispatch function dispatches to the first matching thunk/reducer/side-effect in the Bloc.