BaseViewModel

abstract class BaseViewModel<State, Event>(initialState: State) : ViewModel

Base ViewModel with a StateFlow-driven unidirectional data flow.

Provides common patterns for state management matching TCA's reducer pattern: a single immutable state snapshot, updated only through updateState, and a single onEvent entry point for user actions.

Constructors

Link copied to clipboard
constructor(initialState: State)

Properties

Link copied to clipboard
val state: StateFlow<State>

Functions

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard
Link copied to clipboard
abstract fun onEvent(event: Event)

Handle user events (actions). Override to implement event handling logic.