Skip to content

Instantly share code, notes, and snippets.

@manuelvicnt
Created January 15, 2021 15:35
Show Gist options
  • Save manuelvicnt/34bbc0f31221caa8dbeba40640817f82 to your computer and use it in GitHub Desktop.
Save manuelvicnt/34bbc0f31221caa8dbeba40640817f82 to your computer and use it in GitHub Desktop.
@ViewModelScoped // Scopes type to the ViewModel
class UserInputAuthData(
private val handle: SavedStateHandle // Default binding in ViewModelComponent
) { /* Cached data and logic here */ }
class RegistrationViewModel(
private val userInputAuthData: UserInputAuthData,
private val validateUsernameUseCase: ValidateUsernameUseCase,
private val validatePasswordUseCase: ValidatePasswordUseCase
) : ViewModel() { /* ... */ }
class LoginViewModel(
private val userInputAuthData: UserInputAuthData,
private val validateUsernameUseCase: ValidateUsernameUseCase,
private val validatePasswordUseCase: ValidatePasswordUseCase
) : ViewModel() { /* ... */ }
class ValidateUsernameUseCase(
private val userInputAuthData: UserInputAuthData,
private val repository: UserRepository
) { /* ... */ }
class ValidatePasswordUseCase(
private val userInputAuthData: UserInputAuthData,
private val repository: UserRepository
) { /* ... */ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment