-
- All Implemented Interfaces:
-
java.lang.AutoCloseable,pro.respawn.flowmvi.MVIProvider,pro.respawn.flowmvi.MutableStore,pro.respawn.flowmvi.api.ActionProvider,pro.respawn.flowmvi.api.ActionReceiver,pro.respawn.flowmvi.api.Container,pro.respawn.flowmvi.api.IntentReceiver,pro.respawn.flowmvi.api.Provider,pro.respawn.flowmvi.api.StateProvider,pro.respawn.flowmvi.api.StateReceiver,pro.respawn.flowmvi.api.Store
@Deprecated(message = MVIViewModel is now deprecated. A better API was designed for MVIViewModels that is multiplatform, extensible, and uses composition instead of locking you into a specific base class. Please consult the migration guide or the documentation to learn how to migrate. , replaceWith = @ReplaceWith(imports = {pro.respawn.flowmvi.api.Container}, expression = Container<S, I, A>)) public abstract class MVIViewModel<S extends MVIState, I extends MVIIntent, A extends MVIAction> extends ViewModel implements MutableStore<S, I, A>, Container<S, I, A>, MVIProvider<S, I, A>
A ViewModel that uses MVIStore internally to provide a convenient base class. Only functions of the MVIProvider are made public, everything else happens through intents and actions. If you want to add error handling for reduce, override recover (default implementation throws immediately)
-
-
Constructor Summary
Constructors Constructor Description MVIViewModel(S initial)
-
Method Summary
Modifier and Type Method Description MutableStore<S, I, A>getStore()Overriding this field, don't forget to call MVIStore.start yourself. StringgetName()Flow<A>getActions()StateFlow<S>getStates()final SgetInitial()SgetState()UnituseState(Function1<S, S> block)Unitsend(I intent)Unitsend(A action)Unitemit(A action)Unitemit(I intent)Unitclose()UnitupdateState(SuspendFunction1<S, S> transform)<R extends Any> RwithState(SuspendFunction1<S, R> block)Jobstart(CoroutineScope scope)Jobsubscribe(CoroutineScope $self, SuspendFunction1<Provider<S, I, A>, Unit> block)-
Methods inherited from class pro.respawn.flowmvi.android.MVIViewModel
addCloseable, clear, getTag, onCleared, setTagIfAbsent -
Methods inherited from class pro.respawn.flowmvi.MutableStore
action -
Methods inherited from class pro.respawn.flowmvi.api.Store
intent -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
MVIViewModel
MVIViewModel(S initial)
-
-
Method Detail
-
getStore
MutableStore<S, I, A> getStore()
Overriding this field, don't forget to call MVIStore.start yourself.
-
getActions
Flow<A> getActions()
-
getInitial
final S getInitial()
-
updateState
Unit updateState(SuspendFunction1<S, S> transform)
-
start
Job start(CoroutineScope scope)
-
-
-
-