Skip to content
This repository was archived by the owner on Jun 6, 2019. It is now read-only.

A Retrofit 2 adapter for Kotlin coroutine's Deferred type.

License

Notifications You must be signed in to change notification settings

JakeWharton/retrofit2-kotlin-coroutines-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e7f4d91 · Jun 5, 2019

History

28 Commits
Dec 27, 2017
Sep 13, 2018
Jul 28, 2018
Dec 27, 2017
Dec 27, 2017
Sep 22, 2018
Dec 27, 2017
Jun 5, 2019
Aug 3, 2018
May 28, 2019
Sep 22, 2018
Dec 27, 2017
Dec 27, 2017

Repository files navigation

Kotlin Coroutine Adapter (DEPRECATED)

A Retrofit 2 CallAdapter.Factory for Kotlin coroutine's Deferred.

This library is deprecated. Please migrate to Retrofit 2.6.0 or newer and its built-in suspend support

Usage

Add CoroutineCallAdapterFactory as a Call adapter when building your Retrofit instance:

val retrofit = Retrofit.Builder()
    .baseUrl("https://example.com/")
    .addCallAdapterFactory(CoroutineCallAdapterFactory())
    .build()

Your service methods can now use Deferred as their return type.

interface MyService {
  @GET("/user")
  fun getUser(): Deferred<User>

  // or

  @GET("/user")
  fun getUser(): Deferred<Response<User>>
}

Download

If you are using Kotlin 1.3, download the latest JAR or grab via Maven:

<dependency>
  <groupId>com.jakewharton.retrofit</groupId>
  <artifactId>retrofit2-kotlin-coroutines-adapter</artifactId>
  <version>0.9.2</version>
</dependency>

or Gradle:

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 or grab via Maven:

<dependency>
  <groupId>com.jakewharton.retrofit</groupId>
  <artifactId>retrofit2-kotlin-coroutines-experimental-adapter</artifactId>
  <version>1.0.0</version>
</dependency>

or Gradle:

implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-experimental-adapter:1.0.0'

Snapshots of the development version are available in Sonatype's snapshots repository.

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 at

   http://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.

About

A Retrofit 2 adapter for Kotlin coroutine's Deferred type.

Resources

License

Stars

Watchers

Forks

Packages

No packages published