Skip to content

Instantly share code, notes, and snippets.

@Runman44
Last active November 6, 2018 11:22
Show Gist options
  • Save Runman44/0a26c477ad37c64de9e2df726e256746 to your computer and use it in GitHub Desktop.
Save Runman44/0a26c477ad37c64de9e2df726e256746 to your computer and use it in GitHub Desktop.
enum class ScreenState {
LOADING,
ERROR,
SUCCESS
}
class Response(val state: ScreenState, val data: String?, val error: Throwable?)
fun main(args: Array<String>) {
val response = Response(ScreenState.SUCCESS, "yay", null)
when (response.state) {
ScreenState.SUCCESS -> doStuff(response.data!!)
ScreenState.LOADING -> { }
ScreenState.ERROR -> { }
}
}
fun doStuff(data: String) {
//NO-OP
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment