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
- Host: GitHub
- URL: https://github.com/bhoominn/retrofitmeetscoroutine
- Owner: bhoominn
- License: mit
- Created: 2019-11-10T05:46:04.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-17T20:30:58.000Z (almost 6 years ago)
- Last Synced: 2025-01-30T02:25:51.678Z (8 months ago)
- Language: Kotlin
- Homepage:
- Size: 138 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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
})