Skip to content

Instantly share code, notes, and snippets.

@motorro
Created August 7, 2022 13:15
Show Gist options
  • Save motorro/bf0eeb82f5bed6e2ff7a8e1649964d0b to your computer and use it in GitHub Desktop.
Save motorro/bf0eeb82f5bed6e2ff7a8e1649964d0b to your computer and use it in GitHub Desktop.
Complete state with dependencies
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