Created
November 20, 2019 20:26
-
-
Save elihart/0addb34a38592796c7fbb9003db73344 to your computer and use it in GitHub Desktop.
MvRxViewModelWithBoldOption
This file contains hidden or 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 TextOptions(val bold: Boolean = false) | |
data class TextState(val text: String? = null, val options: TextOptions = TextOptions()) : MvRxState | |
class TextViewModel(state: TextState) : MvRxViewModel<TextState>(state) { | |
fun setText(text: String) { | |
setState { | |
copy(text = text) | |
} | |
} | |
fun setBold(bold: Boolean) { | |
setState { | |
copy(options = options.copy(bold = bold) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment