Skip to content

drakeet/retrofit-agera-call-adapter

Repository files navigation

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.

About

Retrofit Agera Call Adapter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages