Skip to content

Instantly share code, notes, and snippets.

@PierceZ
Created October 2, 2017 21:46
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 PierceZ/896d91163d25231772eaa58130b893ed to your computer and use it in GitHub Desktop.
Save PierceZ/896d91163d25231772eaa58130b893ed to your computer and use it in GitHub Desktop.
public class ZooListViewModel extends BaseViewModel {
private MutableLiveData<List<Zoo>> mZoosLiveData;
public ZooListViewModel() {
mZoosLiveData = new MutableLiveData<>();
DataSubscription subscription = ZooRepository.subscribeToZooList(this::refreshZoos);
addSubscription(subscription);
}
private void refreshZoos(List<Zoo> zoos) {
mZoosLiveData.postValue(zoos);
}
public LiveData<List<Zoo>> getZoos() {
return mZoosLiveData;
}
public void refreshZoos() {
ZooRepository.refreshZoos();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment