Package 

Class MVIViewModel

  • All Implemented Interfaces:
    java.lang.AutoCloseable , pro.respawn.flowmvi.MutableStore , pro.respawn.flowmvi.api.ActionReceiver , pro.respawn.flowmvi.api.Container , pro.respawn.flowmvi.api.IntentReceiver , 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>
                        

    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)

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final MutableStore<S, I, A> store
      private final String name
      private final S initial
    • 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.
      String getName()
      final S getInitial()
      Unit useState(Function1<S, S> block)
      Unit send(I intent)
      Unit send(A action)
      Unit emit(I intent)
      Unit close()
      Unit updateState(SuspendFunction1<S, S> transform)
      <R extends Any> R withState(SuspendFunction1<S, R> block)
      Job start(CoroutineScope scope)
      Job subscribe(CoroutineScope $self, SuspendFunction1<Provider<S, I, A>, Unit> block)
      • Methods inherited from class pro.respawn.flowmvi.MutableStore

        action, emit
      • Methods inherited from class pro.respawn.flowmvi.android.MVIViewModel

        addCloseable, clear, getTag, onCleared, setTagIfAbsent
      • 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