BaseMviViewModel

abstract class BaseMviViewModel<S : MviState, I : MviIntent, E : MviEffect>(initialState: S, val effectDispatcher: CoroutineDispatcher) : ViewModel, MviViewModel<S, I, E> (source)

Coordinates BaseMviViewModel behavior in the SDAI core UI layer.

Author

Dmitriy Moroz

Constructors

Link copied to clipboard
constructor(initialState: S, effectDispatcher: CoroutineDispatcher)

Properties

Link copied to clipboard
private val _effect: Channel<E>

Exposes the _effect value used by the SDAI core UI layer.

Link copied to clipboard
private val _state: MutableStateFlow<S>

Exposes the _state value used by the SDAI core UI layer.

Link copied to clipboard
protected val currentState: S

Exposes the currentState value used by the SDAI core UI layer.

Link copied to clipboard
open override val effect: Flow<E>

Exposes the effect value used by the SDAI core UI layer.

Link copied to clipboard
private val effectDispatcher: CoroutineDispatcher

Exposes the effectDispatcher value used by the SDAI core UI layer.

Link copied to clipboard
open override val state: StateFlow<S>

Exposes the state value used by the SDAI core UI layer.

Functions

Link copied to clipboard
expect open fun addCloseable(closeable: AutoCloseable)
expect fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
internal expect fun clear()
Link copied to clipboard
protected fun emitEffect(effect: E)

Executes the emitEffect step in the SDAI core UI layer.

Link copied to clipboard
protected fun emitState(state: S)

Executes the emitState step in the SDAI core UI layer.

Link copied to clipboard
expect fun <T : AutoCloseable> getCloseable(key: String): T?
Link copied to clipboard
protected fun launch(dispatcher: CoroutineDispatcher, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): Job

Executes the launch step in the SDAI core UI layer.

Link copied to clipboard
protected expect open fun onCleared()
Link copied to clipboard
abstract fun processIntent(intent: I)

Executes the processIntent step in the SDAI core UI layer.

Link copied to clipboard
protected fun updateState(mutation: (S) -> S)

Performs the SDAI side effect handled by updateState.