Skip to content

Instantly share code, notes, and snippets.

@psteiger
Last active September 5, 2019 16:44
Show Gist options
  • Select an option

  • Save psteiger/7c1b9d0c16075fd6c69e5d253431172e to your computer and use it in GitHub Desktop.

Select an option

Save psteiger/7c1b9d0c16075fd6c69e5d253431172e to your computer and use it in GitHub Desktop.
class UsersViewModel : ViewModel() {
private val usersSnapLiveData: LiveData<Resource<DataSnapshot>> by lazy {
UsersSnapLiveData()
}
val usersLiveData: LiveData<Resource<HashMap<String, User>>> by lazy {
usersSnapLiveData.mapLiveDataResource<
DataSnapshot, // from
HashMap<String, User> // to
>(DataSnapshot::getTypedValue) // transformation function
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment