Skip to content

Instantly share code, notes, and snippets.

@OssamaDroid
Created February 10, 2020 00:44
Show Gist options
  • Save OssamaDroid/61fdfc9dd7bbad64640d53133cd0dc7f to your computer and use it in GitHub Desktop.
Save OssamaDroid/61fdfc9dd7bbad64640d53133cd0dc7f to your computer and use it in GitHub Desktop.
results.scan(UIModel.idle(), { _, result ->
when (result) {
SubmitResult.InFlight, CheckNameResult.InFlight -> UIModel.inProgress()
SubmitResult.Success, CheckNameResult.Success -> UIModel.success()
is SubmitResult.Failure -> UIModel.error(result.errorMessage)
is CheckNameResult.Failure -> UIModel.error(result.errorMessage)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment