Created
October 2, 2017 21:46
-
-
Save PierceZ/896d91163d25231772eaa58130b893ed to your computer and use it in GitHub Desktop.
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
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