Created
May 29, 2017 14:58
-
-
Save shahbazahmed1269/407826a8bc3f7fb1e5dba660e93446f4 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 ListIssuesViewModel extends ViewModel { | |
private MediatorLiveData<ApiResponse> mApiResponse; | |
private IssueRepository mIssueRepository; | |
// No argument constructor | |
public ListIssuesViewModel() { | |
mApiResponse = new MediatorLiveData<>(); | |
mIssueRepository = new IssueRepositoryImpl(); | |
} | |
@NonNull | |
public LiveData<ApiResponse> getApiResponse() { | |
return mApiResponse; | |
} | |
public LiveData<ApiResponse> loadIssues(@NonNull String user, String repo) { | |
mApiResponse.addSource( | |
mIssueRepository.getIssues(user, repo), | |
apiResponse -> mApiResponse.setValue(apiResponse) | |
); | |
return mApiResponse; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment