An open API service indexing awesome lists of open source software.

https://github.com/bhoominn/retrofitmeetscoroutine

Call API in a very simple way with Kotlin Coroutine and Retrofit
https://github.com/bhoominn/retrofitmeetscoroutine

Last synced: 7 months ago
JSON representation

Call API in a very simple way with Kotlin Coroutine and Retrofit

Awesome Lists containing this project

README

          

# RetrofitMeetsCoroutine

## Retrofit with Coroutine
```
GlobalScopeExt(this) {
getUser(onApiSuccess = {
//Handle Response
showUser(it)
})
}
```

## Retrofit without Coroutine
### GET Example
```
getResponse(getApis().getUser(), onApiSuccess = {
//Handle Response
txtName.text = it.name
}, onApiError = {
//Handle Api Error
toast(it)
}, onNetworkError = {
//Handle No Internet Connection
})

```

### POST Example
```
val requestModel = RequestModel()
requestModel.name = "Bhoomin"

getResponse(getApis().createUser(requestModel), onApiSuccess = {
txtName.text = it.name
}, onApiError = {
//Handle Api Error
toast(it)
}, onNetworkError = {
//Handle No Internet Connection
})