Skip to content

Instantly share code, notes, and snippets.

@motorro
Created August 7, 2022 13:28
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/3b939440154ffde477cd16688f948124 to your computer and use it in GitHub Desktop.
Save motorro/3b939440154ffde477cd16688f948124 to your computer and use it in GitHub Desktop.
Using state factory
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