Created
January 24, 2020 12:46
-
-
Save iambaljeet/b4d5109a55a450f6f262c76e682a0bad to your computer and use it in GitHub Desktop.
This file contains hidden or 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
object DataRepository { | |
var apiService: ApiService? = null | |
var searchResultsLiveData: MutableLiveData<GenericDataModel<SearchResultModel>?> = MutableLiveData() | |
init { | |
apiService = | |
ApiProvider.createService( | |
ApiService::class.java | |
) | |
} | |
suspend fun getSearchResults(searchQuery: String?) { | |
searchResultsLiveData.postValue(null) | |
val result = apiService?.getResult(searchQuery) | |
val genericDataModel = | |
GenericDataModel( | |
result?.isSuccessful, | |
result?.body(), | |
result?.message() | |
) | |
searchResultsLiveData.postValue(genericDataModel) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment