-
public final class MVIComposableKt
-
-
Method Summary
Modifier and Type Method Description final static <S extends MVIState, I extends MVIIntent, A extends MVIAction, VM extends MVIProvider<S, I, A>> UnitMVIComposable(VM provider, 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, VM extends MVIProvider<S, I, A>> Unit MVIComposable(VM provider, 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. Usage:
@Composable fun HomeScreen() = MVIComposable(getViewModel<HomeViewModel>()) { state -> consume { action -> when(action) { /*...*/ } } when(state) { //use state to render content } }- Parameters:
provider- an MVIProvider (usually a 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.
-
-
-
-