Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JakeWharton/retrofit2-kotlin-coroutines-adapter
A Retrofit 2 adapter for Kotlin coroutine's Deferred type.
https://github.com/JakeWharton/retrofit2-kotlin-coroutines-adapter
Last synced: 3 months ago
JSON representation
A Retrofit 2 adapter for Kotlin coroutine's Deferred type.
- Host: GitHub
- URL: https://github.com/JakeWharton/retrofit2-kotlin-coroutines-adapter
- Owner: JakeWharton
- License: apache-2.0
- Archived: true
- Created: 2017-12-27T15:10:17.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-05T18:32:47.000Z (over 5 years ago)
- Last Synced: 2024-08-01T01:28:02.249Z (6 months ago)
- Language: Kotlin
- Size: 130 KB
- Stars: 1,973
- Watchers: 57
- Forks: 129
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-kotlin - retrofit2-kotlin-coroutines-adapter - A Retrofit 2 adapter for Kotlin coroutine's Deferred type. (Libraries)
README
Kotlin Coroutine Adapter (DEPRECATED)
========================A Retrofit 2 `CallAdapter.Factory` for [Kotlin coroutine's][1] `Deferred`.
This library is deprecated. Please migrate to Retrofit 2.6.0 or newer and its [built-in `suspend` support](https://github.com/square/retrofit/blob/master/CHANGELOG.md#version-260-2019-06-05)
Usage
-----Add `CoroutineCallAdapterFactory` as a `Call` adapter when building your `Retrofit` instance:
```kotlin
val retrofit = Retrofit.Builder()
.baseUrl("https://example.com/")
.addCallAdapterFactory(CoroutineCallAdapterFactory())
.build()
```Your service methods can now use `Deferred` as their return type.
```kotlin
interface MyService {
@GET("/user")
fun getUser(): Deferred// or
@GET("/user")
fun getUser(): Deferred>
}
```Download
--------If you are using Kotlin 1.3, download [the latest JAR][2] or grab via [Maven][3]:
```xmlcom.jakewharton.retrofit
retrofit2-kotlin-coroutines-adapter
0.9.2```
or [Gradle][3]:
```groovy
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
```If you are using Kotlin pre-1.3 and experimental coroutines, download [its latest JAR][4] or grab
via [Maven][5]:
```xmlcom.jakewharton.retrofit
retrofit2-kotlin-coroutines-experimental-adapter
1.0.0```
or [Gradle][5]:
```groovy
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-experimental-adapter:1.0.0'
```Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap].
License
=======Copyright 2017 Jake Wharton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.[1]: https://kotlinlang.org/docs/reference/coroutines.html
[2]: https://search.maven.org/remote_content?g=com.jakewharton.retrofit&a=retrofit2-kotlin-coroutines-adapter&v=LATEST
[3]: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.jakewharton.retrofit%22%20a%3A%22retrofit2-kotlin-coroutines-adapter%22
[4]: https://search.maven.org/remote_content?g=com.jakewharton.retrofit&a=retrofit2-kotlin-coroutines-experimental-adapter&v=LATEST
[5]: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.jakewharton.retrofit%22%20a%3A%22retrofit2-kotlin-coroutines-experimental-adapter%22
[snap]: https://oss.sonatype.org/content/repositories/snapshots/