Package 

Class StoreViewModel

  • All Implemented Interfaces:
    java.lang.AutoCloseable , pro.respawn.flowmvi.api.Container , pro.respawn.flowmvi.api.ImmutableContainer , pro.respawn.flowmvi.api.ImmutableStore , pro.respawn.flowmvi.api.IntentReceiver , pro.respawn.flowmvi.api.Store

    
    public class StoreViewModel<S extends MVIState, I extends MVIIntent, A extends MVIAction>
    extends ViewModel implements Store<S, I, A>, Container<S, I, A>
                        

    An extendable class for creating a ViewModel that directly uses a delegate to act as a Store. There are 2 possible ways to use this class:

    • Create StoreViewModels and inject your desired Store as a constructor parameter, then use a qualified name or other type of dependency injection to resolve the needed ViewModel.

    • Subclass StoreViewModel for each ViewModel that is being used, build the Store using constructor params, with assistance from DI, and then inject that ViewModel by its direct type.

    Most DI frameworks struggle with type erasure when it comes to injecting generic classes, so one of 2 ways outlined above can be used to resolve the conflicts.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final Store<S, I, A> store
      private final String name
      private final S state
    • Method Summary

      Modifier and Type Method Description
      final Store<S, I, A> getStore()
      String getName()
      S getState()
      • Methods inherited from class pro.respawn.flowmvi.android.StoreViewModel

        addCloseable, clear, getTag, onCleared, setTagIfAbsent
      • Methods inherited from class pro.respawn.flowmvi.api.Store

        close, emit, intent, send, start, subscribe
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait