toObservable
fun <State : Any, Action : Any, SideEffect : Any> Bloc<State, Action, SideEffect>.toObservable(): BlocObservable<State, SideEffect>
If a components implements the BlocObservableOwner interface it needs to provide
val observable: BlocObservable<State, SideEffect>
Content copied to clipboard
This extension functions converts a Bloc into that BlocObservable:
override val observable = bloc.toObservable()
Content copied to clipboard
fun <State : Any, Action : Any, SideEffect : Any> List<Bloc<State, Action, SideEffect>>.toObservable(): BlocObservable<State, SideEffect>
The assumption is that all Blocs use the same BlocState with the same type parameters (enforced at compile time) but also that they share the same instance of a BlocState (not enforced at all). Under that assumption we only need to observe the state of the first Bloc to observe all state changes. The edge-case that one passes in multiple Blocs using different BlocStates could be covered by using a UUID for BlocState instances and then verify that all BlocStates have the same UUID but that would be over-engineering imo.
fun <State : Any, Action : Any, SideEffect : Any> Bloc<State, Action, SideEffect>.toObservable(bloc: Bloc<State, Action, SideEffect>): BlocObservable<State, SideEffect>
Same as above but combine just two Blocs to BlocObservable.