Created
November 27, 2019 19:14
-
-
Save Zhuinden/20cd4b8b497f595eee7d4dc8a5333f48 to your computer and use it in GitHub Desktop.
Anemic Repository 3
This file contains 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 MyViewModel( | |
savedStateHandle: SavedStateHandle, | |
private val userDao: UserDao | |
): ViewModel() { | |
private val selectedUserId: MutableLiveData<String> = | |
savedStateHandle.getLiveData("selectedUserId") | |
val selectedUser: LiveData<User> = selectedUserId.switchMap { id -> | |
userDao.getUserByIdWithChanges(id) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment