Skip to content

Instantly share code, notes, and snippets.

@mcatta
Created October 25, 2022 20:13
Show Gist options
  • Save mcatta/c6ecd09b92dc5bd6413867b4c913e785 to your computer and use it in GitHub Desktop.
Save mcatta/c6ecd09b92dc5bd6413867b4c913e785 to your computer and use it in GitHub Desktop.
@OptIn(FlowPreview::class, ExperimentalCoroutinesApi::class)
abstract class AbsStateViewModel<State: Any, Action: Any>(
private val stateMachine: FlowReduxStateMachine<State, Action>
): BaseViewModel() {
@Composable
fun rememberState() = stateMachine.rememberState()
fun dispatch(action: Action) = viewModelScope.launch {
stateMachine.dispatch(action = action)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment