• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

JakeWharton/retrofit2-kotlin-coroutines-adapter: A Retrofit 2 adapter for Kotlin ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

JakeWharton/retrofit2-kotlin-coroutines-adapter

开源软件地址(OpenSource Url):

https://github.com/JakeWharton/retrofit2-kotlin-coroutines-adapter

开源编程语言(OpenSource Language):

Kotlin 63.3%

开源软件介绍(OpenSource Introduction):

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.



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap