Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sealed class MVIJetpackComposeViewState {
@Composable
abstract fun buildUI()
object Loading : MyViewState() {
@Composable
override fun buildUI() {
// Loading which is not provided yet
}
}
class Error(private val reason: String, private val retry: () -> Unit) : MyViewState() {
@Composable
override fun buildUI() {
Padding(padding = 16.dp) {
Column {
Text(text = reason, style = +themeTextStyle { body1 })
TransparentButton(text = "Retry", onClick = {
retry()
})
}
}
}
}
class Success(private val body: String) : MyViewState() {
@Composable
override fun buildUI() {
Padding(padding = 16.dp) {
Text(text = body, style = +themeTextStyle { body1 })
}
}
}
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.