Skip to content

Instantly share code, notes, and snippets.

@motorro
Last active August 14, 2022 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motorro/d15ff76f9a5610d613232a9b2474b80d to your computer and use it in GitHub Desktop.
Save motorro/d15ff76f9a5610d613232a9b2474b80d to your computer and use it in GitHub Desktop.
Email check state
class EmailCheckState(
context: WelcomeContext,
private val data: WelcomeDataState,
private val checkEmail: CheckEmail
) : WelcomeState(context) {
private val email = requireNotNull(data.email) {
"Email is not provided"
}
override fun doStart() {
setUiState(renderer.renderChecking(data))
stateScope.launch {
val exists = checkEmail(email)
if (exists) {
setMachineState(factory.loginFlow(data))
} else {
setMachineState(factory.registrationFlow(data))
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment