StoreViewModel

open class StoreViewModel<S : MVIState, I : MVIIntent, A : MVIAction>(store: Store<S, I, A>, start: Boolean = true) : ViewModel, 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:

  1. 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.

  2. 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.

Constructors

Link copied to clipboard
constructor(container: Container<S, I, A>, start: Boolean = true)
constructor(store: Store<S, I, A>, start: Boolean = true)

Properties

Link copied to clipboard
open override val name: String?
Link copied to clipboard
open override val state: S
Link copied to clipboard
override val store: Store<S, I, A>

Functions

Link copied to clipboard
Link copied to clipboard
open override fun close()
Link copied to clipboard
open suspend override fun emit(intent: I)
Link copied to clipboard
open override fun intent(intent: I)
Link copied to clipboard
open override fun start(scope: CoroutineScope): Job
Link copied to clipboard
open override fun CoroutineScope.subscribe(block: suspend Provider<S, I, A>.() -> Unit): Job