Created
August 7, 2022 13:15
-
-
Save motorro/bf0eeb82f5bed6e2ff7a8e1649964d0b to your computer and use it in GitHub Desktop.
Complete state with dependencies
This file contains hidden or 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, | |
private val data: LoginDataState, | |
private val checkCredentials: CheckCredentials | |
) : LoginState(context) { | |
override fun doStart() { | |
// Use a context-provided dependency | |
setUiState(renderer.renderLoading(data)) | |
} | |
/** | |
* Factory updated to pass common context | |
*/ | |
@LoginScope | |
class Factory @Inject constructor(private val checkCredentials: CheckCredentials) { | |
operator fun invoke( | |
context: LoginContext, | |
data: LoginDataState | |
): LoginState = CredentialsCheckState( | |
context, | |
data, | |
checkCredentials | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment