Skip to content

Instantly share code, notes, and snippets.

View vitalikas's full-sized avatar

Vitalikas vitalikas

  • Lithuania
View GitHub Profile
@galex
galex / MVIViewModel.kt
Created July 3, 2025 03:55
Back to the original MVIViewModel!
abstract class MVIViewModel<State, Event>(
protected val savedStateHandle: SavedStateHandle? = null,
) : ViewModel() {
private val _uiState by lazy { MutableStateFlow(initialState()) }
val uiState get() = _uiState.asStateFlow()
fun update(block: State.() -> State) {
_uiState.update(block)
}