Skip to content

Instantly share code, notes, and snippets.

@hieuwu
Created August 1, 2023 14:35
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 hieuwu/4a6498dede9b1074bbc383e6553dd05c to your computer and use it in GitHub Desktop.
Save hieuwu/4a6498dede9b1074bbc383e6553dd05c to your computer and use it in GitHub Desktop.
@HiltViewModel
class SignUpViewModel @Inject constructor(
private val authenticationRepository: AuthenticationRepository
) : ViewModel() {
private val _email = MutableStateFlow("")
val email: Flow<String> = _email
private val _password = MutableStateFlow("")
val password = _password
fun onEmailChange(email: String) {
_email.value = email
}
fun onPasswordChange(password: String) {
_password.value = password
}
fun onSignUp() {
viewModelScope.launch {
authenticationRepository.signUp(
email = _email.value,
password = _password.value
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment