Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Repository {
- // ....
- fun login(user:String, password:String): LiveData<Status> { /* ... */ }
- }
- class LoginViewModel : ViewModel() {
- @Inject
- lateinit var repo: Repository
- private var auth = MutableLiveData<User>()
- private var showErrorEvent = SingleLiveEvent<String>()
- private var showSuccessEvent = SingleLiveEvent<String>()
- private val authenticationStatus = Transformations.switchMap(auth, { data ->
- repo.login(data.user, data.password)
- })
- // Called from UI
- fun performLogin(data:Data){
- auth.value = data
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement