All Projects → RobertZagorski → RetrofitRxErrorHandler

RobertZagorski / RetrofitRxErrorHandler

Licence: Apache-2.0 license
Hardening Retrofit RxJaxa API Layer against random errors

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to RetrofitRxErrorHandler

Offlinesampleapp
Sample Offline-First MVVM app that uses Android Priority Job Queue, Room, Retrofit2, LiveData, LifecycleObserver, RxJava2, Dagger Android
Stars: ✭ 653 (+4253.33%)
Mutual labels:  reactive-programming, rxjava2, retrofit2
Vertx Blueprint Todo Backend
Vert.x Blueprint Project - A reactive todo-backend implementation using Vert.x and various persistence
Stars: ✭ 169 (+1026.67%)
Mutual labels:  reactive-programming, rxjava2
Android-Code-Demos
📦 Android learning code demos.
Stars: ✭ 41 (+173.33%)
Mutual labels:  rxjava2, retrofit2
Atoms-mvp
A component architecture for android applications based on MVP
Stars: ✭ 63 (+320%)
Mutual labels:  rxjava2, retrofit2
Clean-MVVM-NewsApp
Android News app developed using Clean + MVVM architecture
Stars: ✭ 52 (+246.67%)
Mutual labels:  rxjava2, retrofit2
Pandaeye
一款基于 mvp+rxjava+retrofit+Picasso 的应用,内容来自知乎日报,网易新闻,咪咕视频。实现了新闻列表的磁盘缓存
Stars: ✭ 242 (+1513.33%)
Mutual labels:  rxjava2, retrofit2
Rxdownloader
- Reactive Extension Library for Android to download files
Stars: ✭ 40 (+166.67%)
Mutual labels:  reactive-programming, rxjava2
Sunset-hadith
Islamic app written with Kotlin, using KTOR + coroutines + flow + MVVM + Android Jetpack + Navigation component. Old version using RxJava + Retrofit + OKHttp
Stars: ✭ 26 (+73.33%)
Mutual labels:  rxjava2, retrofit2
InstantAppStarter
Starter Project Structure for Android Instant app. https://blog.mindorks.com/android-mvp-architecture-with-instant-app-support-11ba48241a82
Stars: ✭ 44 (+193.33%)
Mutual labels:  rxjava2, retrofit2
stockwatcher
stockwatcher, a modern android development stack showcase
Stars: ✭ 62 (+313.33%)
Mutual labels:  rxjava2, retrofit2
MVPSamples
🚀(Java 版)快速搭建 MVP + RxJava + Retrofit + EventBus 的框架,方便快速开发新项目、减少开发成本。
Stars: ✭ 113 (+653.33%)
Mutual labels:  rxjava2, retrofit2
Pursuit-Core-Android
Pursuit Core Android
Stars: ✭ 45 (+200%)
Mutual labels:  rxjava2, retrofit2
Wanandroid
WanAndroid客户端,项目基于 Material Design + MVP +dagger2 + RxJava + Retrofit + Glide + greendao 等架构进行设计实现,极力打造一款 优秀的玩Android https://www.wanandroid.com 客户端,是一个不错的Android应用开发学习参考项目
Stars: ✭ 223 (+1386.67%)
Mutual labels:  rxjava2, retrofit2
movies
An example approach for modularization, reactive clean architecture and persistancy.
Stars: ✭ 110 (+633.33%)
Mutual labels:  reactive-programming, retrofit2
Bilibili
基于ijkplayer+rxjava+retrofit,组件化思想,实现一个仿B站的Android客户端
Stars: ✭ 221 (+1373.33%)
Mutual labels:  rxjava2, retrofit2
Awesome Wanandroid
⚡致力于打造一款极致体验的 http://www.wanandroid.com/ 客户端,知识和美是可以并存的哦QAQn(*≧▽≦*)n
Stars: ✭ 2,525 (+16733.33%)
Mutual labels:  rxjava2, retrofit2
Httprequest
基于Retrofit2+RxJava2+OkHttp3的网络请求框架,可以完美的应用到组件化、MVP模式等项目中
Stars: ✭ 181 (+1106.67%)
Mutual labels:  rxjava2, retrofit2
Mvvm Android
Build MVVM APP With Kotlin,完整示例见PaoNet
Stars: ✭ 184 (+1126.67%)
Mutual labels:  rxjava2, retrofit2
Android-Starter-Kit
This is up-to-date android studio project for native android application, that is using modern tools and libraries.
Stars: ✭ 16 (+6.67%)
Mutual labels:  rxjava2, retrofit2
Eva
Eva and Wall-e
Stars: ✭ 131 (+773.33%)
Mutual labels:  rxjava2, retrofit2

RetrofitRxErrorHandler


What is it?

RetrofitRxErrorHandler is an attempt to harden Retrofit HTTP API layer against random errors, like timeouts, 500 server errors caused due to server overload or accidental loss of networks (happening especially in mobile applications).

Who should use it?

Everyone who is using Retrofit combined with RxJava and experienced random errors when sending requests.


Usage

  1. Import gradle dependency:

    • Add following lines to you project's main build.gradle:

        buildscript {
            repositories {
                jcenter()
            }
        }
      
    • Add a dependency to application build.gradle:

        compile 'com.rzagorski:retrofitrxerrorhandler:1.1.0'
      
  2. Build the strategy:

      RxCallAdapter rxCallAdapter = new RxCallAdapter.Builder()
                  .addBackoffStrategy(Exponential.init()
                          .addThrowable(HttpException.class)
                          .setMaxRetries(3).build())
                  .build();
    
  3. Add it as Retrofit CallAdapter.Factory:

      Retrofit retrofit = new Retrofit.Builder()
          .addCallAdapterFactory(new RxErrorHandingFactory(rxCallAdapter))
          .build()
    

Options:

  • different backoff strategies (Simple, Exponential)

       Simple.init().(...).build()
    

    or

       Exponential.init().(...).build()
    

Common:

  • reactions to different Throwables

       Exponential.init()
           .addThrowable(HttpException.class)
    
  • reactions to HTTP error codes

       Exponential.init()
           .setResponseCode(500)
    
  • exclusive or inclusive behaviour to Throwables or HTTP error codes

       Exponential.init()
           .exclusive()
    
  • maximum retry count (different for every added strategy)

       Exponential.init()
           .addThrowable(HttpException.class)
           .setBase(2)
           .setMaxRetries(3)
    
  • backup Observable (executed before strategy delay and after every occurrence of error or HTTP response code)

       Exponential.init()
           .addObservable(backupObservable)
    

Exponential:

  • base of exponential function:

        Exponential.init()
            (...)
            .setBase(2)
    

Examples

Look into tests

License

Copyright 2016 Robert Zagórski.

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].