Created
August 7, 2022 13:28
-
-
Save motorro/3b939440154ffde477cd16688f948124 to your computer and use it in GitHub Desktop.
Using state factory
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 CredentialsCheckState(context: LoginContext) : LoginState(context) { | |
// State logic... | |
/** | |
* A part of [process] template to process UI gesture | |
*/ | |
override fun doProcess(gesture: LoginGesture) = when(gesture) { | |
LoginGesture.Back -> onBack() | |
else -> super.doProcess(gesture) | |
} | |
private fun onBack() { | |
// Use provided factory to create a new state | |
setMachineState(factory.passwordEntry(data)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment