Last active
August 14, 2022 15:38
-
-
Save motorro/d15ff76f9a5610d613232a9b2474b80d to your computer and use it in GitHub Desktop.
Email check state
This file contains 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
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