Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple mvrx sample
data class HelloWorldState(val title: String = "Hello World") : MvRxState
class HelloWorldViewModel(initialState: HelloWorldState) : MyBaseMvRxViewModel<HelloWorldState>(initialState, debugMode = BuildConfig.DEBUG) {
fun getMoreExcited() = setState { copy(title = "$title!") }
}
class HelloWorldFragment : BaseFragment() {
private val viewModel: HelloWorldViewModel by fragmentViewModel()
override fun EpoxyController.buildModels() = withState(viewModel) { state ->
header {
title(state.title)
}
basicRow {
onClick { viewModel.getMoreExcited() }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.