Last active
August 13, 2019 21:54
-
-
Save bernaferrari/db0676529c1b8924dcd61775ab885692 to your computer and use it in GitHub Desktop.
Simple mvrx sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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