-
- All Implemented Interfaces:
-
java.lang.AutoCloseable,pro.respawn.flowmvi.api.Container,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.
-
-
Constructor Summary
Constructors Constructor Description StoreViewModel(Container<S, I, A> container)StoreViewModel(Store<S, I, A> store)
-
Method Summary
-
Methods inherited from class pro.respawn.flowmvi.android.StoreViewModel
addCloseable, clear, getTag, onCleared, setTagIfAbsent -
Methods inherited from class pro.respawn.flowmvi.api.ImmutableStore
close -
Methods inherited from class pro.respawn.flowmvi.api.Store
emit, intent, send, start, subscribe -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-