Skip to content

Instantly share code, notes, and snippets.

View rickyManalo's full-sized avatar
🙃

halfBlue3 rickyManalo

🙃
View GitHub Profile
@rickyManalo
rickyManalo / gist:0fd37b4c23efdddd28c3e36d787f99a4
Created August 15, 2023 05:53
Retrofit API call and Room update helper
/**
* Handles calling the Retrofit endpoints
* [apiCallFunc] is the Retrofit endpoint you want to call
* During runtime, [V] would be equal to the type wrapped by [Response]
* [V] is returned as the reflection would already be executed during that time
* giving us the contents of the inferred [V]
*/
suspend fun <V> callAPI(apiCallFunc: suspend () -> Response<V>): V? {
val actsResult: Response<V>?
if (utils.isInternetAvailable(ctx)) {