Last active
August 23, 2018 18:16
-
-
Save gpeal/1ec04f9bce2bb1f80605a9f350daf203 to your computer and use it in GitHub Desktop.
MvRx
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) : MvRxViewModel<HelloWorldState>(initialState) { | |
fun getMoreExcited() = setState { copy(title = "$title!") } | |
} | |
class HelloWorldFragment : BaseFragment() { | |
private val viewModel by fragmentViewModel(HelloWorldViewModel::class) | |
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