BlocObservableOwner
A class is a BlocObservableOwner if it holds and exposes a BlocObservable.
Using extension functions, users of that component can subscribe to the bloc's state and side effect updates by subscribing to that component with a one-liner:
component.subscribe(state = ::render, sideEffect = ::sideEffect)
Content copied to clipboard
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
Link copied to clipboard
fun <State : Any, SideEffect : Any> BlocObservableOwner<State, SideEffect>.subscribe(lifecycleOwner: LifecycleOwner, state: suspend (state: State) -> Unit? = null, sideEffect: suspend (sideEffect: SideEffect) -> Unit? = null)
Subscribes to a BlocObservableOwner (typically a ViewModel, a Fragment or an Activity). The subscription is tied to the lifecycle of a LifecycleOwner (normally an Activity or Fragment).
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