-
public final class MVIComposableKt
-
-
Method Summary
Modifier and Type Method Description final static <S extends MVIState, I extends MVIIntent, A extends MVIAction> UnitMVIComposable(Store<S, I, A> store, Lifecycle.State lifecycleState, Function2<ConsumerScope<I, A>, S, Unit> content)A function that introduces ConsumerScope to the content and ensures safe lifecycle-aware and efficient collection of states and actions. -
-
Method Detail
-
MVIComposable
@Composable() final static <S extends MVIState, I extends MVIIntent, A extends MVIAction> Unit MVIComposable(Store<S, I, A> store, Lifecycle.State lifecycleState, Function2<ConsumerScope<I, A>, S, Unit> content)
A function that introduces ConsumerScope to the content and ensures safe lifecycle-aware and efficient collection of states and actions.
Use ConsumerScope.consume to subscribe to the store
Usage:
@Composable fun HomeScreen() = MVIComposable(getViewModel<HomeViewModel>()) { // this: ConsumerScope<S, I, A> consume { action -> when(action) { /*...*/ } } when(state) { //use state to render content } }- Parameters:
store- a Store (usually a androidx.lifecycle.ViewModel) that handles this screen's logiclifecycleState- the minimum lifecycle state, in which the activity must be to receive actions/statescontent- the actual screen content.
-
-
-
-