retrofit-agera-call-adapter

retrofit agera call adapter

License

License

Categories

Categories

Retrofit Net HTTP Clients
GroupId

GroupId

me.drakeet.retrofit2
ArtifactId

ArtifactId

adapter-agera
Last Version

Last Version

2.2.0-beta
Release Date

Release Date

Type

Type

aar
Description

Description

retrofit-agera-call-adapter
retrofit agera call adapter
Project URL

Project URL

https://github.com/drakeet/retrofit-agera-call-adapter
Source Code Management

Source Code Management

https://github.com/drakeet/retrofit-agera-call-adapter

Download adapter-agera

How to add to project

<!-- https://jarcasting.com/artifacts/me.drakeet.retrofit2/adapter-agera/ -->
<dependency>
    <groupId>me.drakeet.retrofit2</groupId>
    <artifactId>adapter-agera</artifactId>
    <version>2.2.0-beta</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/me.drakeet.retrofit2/adapter-agera/
implementation 'me.drakeet.retrofit2:adapter-agera:2.2.0-beta'
// https://jarcasting.com/artifacts/me.drakeet.retrofit2/adapter-agera/
implementation ("me.drakeet.retrofit2:adapter-agera:2.2.0-beta")
'me.drakeet.retrofit2:adapter-agera:aar:2.2.0-beta'
<dependency org="me.drakeet.retrofit2" name="adapter-agera" rev="2.2.0-beta">
  <artifact name="adapter-agera" type="aar" />
</dependency>
@Grapes(
@Grab(group='me.drakeet.retrofit2', module='adapter-agera', version='2.2.0-beta')
)
libraryDependencies += "me.drakeet.retrofit2" % "adapter-agera" % "2.2.0-beta"
[me.drakeet.retrofit2/adapter-agera "2.2.0-beta"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

retrofit agera call adapter

License maven-central

version name: 2.2.0-beta, version code: 6

Sample

repository = Repositories.repositoryWithInitialValue(INITIAL_VALUE)
    .observe()
    .onUpdatesPerLoop()
    .goTo(networkExecutor)
    .attemptGetFrom(service.android())
    .orSkip()
    .thenTransform(gankToTitleArray)
    .compile();

Usage

To add a dependency using Gradle:

compile 'me.drakeet.retrofit2:adapter-agera:2.2.0-beta'

compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.google.android.agera:agera:1.3.0'

It supports Supplier<Result<T>> and Supplier<Result<Response<T>>>,
with retrofit2, you could write your service interface like this:

interface Service {
    @GET("1") Supplier<Result<Gank>> android();
    @GET("{page}") Supplier<Result<Response<Gank>>> android(@Path("page") int page);
    @DELETE("/xxx") Supplier<Result<Void>> deleteXXX();
}

And config your retrofit with agera call adapter, like this:

Retrofit retrofit = new Retrofit.Builder()
    .baseUrl("http://drakeet.me/")
    .client(new OkHttpClient())
    .addCallAdapterFactory(AgeraCallAdapterFactory.create())
    .addConverterFactory(GsonConverterFactory.create())
    .build();
final Service service = retrofit.create(Service.class);

Addition

Agera Event Bus

TODO

  • Add a new interface (Naming)<T> extends Supplier<Result<T>>

Hope you will enjoy it : )

License

Copyright (C) 2016 drakeet.
   http://drakeet.me
   
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.

Versions

Version
2.2.0-beta
2.1.0
2.0.4
2.0.3
2.0.2