All Projects → Commit451 → Reptar

Commit451 / Reptar

Licence: apache-2.0
Roaring RxJava

Programming Languages

java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to Reptar

Easygank
💊 The project build framework based on the Rx series and MVP pattern.
Stars: ✭ 750 (+657.58%)
Mutual labels:  rxjava, rxandroid
Afmall
A pure shopping App based on Kotlin + ARouter + MVP + RxJava2 + Retrofit + Dagger2 + 七牛云 + Glide
Stars: ✭ 20 (-79.8%)
Mutual labels:  rxjava, rxandroid
Rxjavasample
RxJava Sample
Stars: ✭ 811 (+719.19%)
Mutual labels:  rxjava, rxandroid
Androidrapidlibrary
Android 快速开发库,主要想实现一条属于自己的开发框架。包括网络访问,数据,UI等等
Stars: ✭ 577 (+482.83%)
Mutual labels:  rxjava, rxandroid
Mvpandroid
Sample app to demonstrate MVP (Model - View - Presenter) architecture in android
Stars: ✭ 91 (-8.08%)
Mutual labels:  rxjava, rxandroid
Aosf
AOSF:全称为Android Open Source Framework,即Android优秀开源框架汇总。包含:网络请求okhttp,图片下载glide,数据库greenDAO,链式框架RxJava,组件路由ARouter,消息传递通信EventBus,热更新Tinker,插件化框架Replugin,文件下载FileDownloaer,图片选择PhotoPicker,图片滤镜/毛玻璃等特效处理,GIF图片展示控件,图片九宫格控件NineGridView,对话框Dialog,导航指示器ViewpagerIndicator,进度条ProgressWheel,下拉刷新SmartRefreshLayout,key-value高效数据存储MMKV等,应有尽有。
Stars: ✭ 601 (+507.07%)
Mutual labels:  rxjava, rxandroid
Rxjava2 Operators Magician
你用不惯 RxJava,只因缺了这把钥匙 🔑 You are not used to RxJava, just because of the lack of this key.
Stars: ✭ 868 (+776.77%)
Mutual labels:  rxjava, rxandroid
Rxbus
🚌 The RxBus as steady as an old dog.
Stars: ✭ 334 (+237.37%)
Mutual labels:  rxjava, rxandroid
Newspaper
An aggregated newspaper app containing news from 10+ local news publishers in Hong Kong. Made with ❤
Stars: ✭ 82 (-17.17%)
Mutual labels:  rxjava, rxandroid
Aiyagirl
🔥 爱吖妹纸(含 Kotlin 分支版本)——Retrofit + RxJava + MVP 架构 APP 体验代码家的干货集中营 Gank.io,福利多多,不容错过
Stars: ✭ 1,109 (+1020.2%)
Mutual labels:  rxjava, rxandroid
Rxjava2 Android Samples
RxJava 2 Android Examples - Migration From RxJava 1 to RxJava 2 - How to use RxJava 2 in Android
Stars: ✭ 4,950 (+4900%)
Mutual labels:  rxjava, rxandroid
Android Mvvm Rx3 Dagger2 Navcomponent
Implemented using MVVM, LiveData, Room, RX3, Dagger2, Coil, View Binding, Navigation Component and AndroidX
Stars: ✭ 72 (-27.27%)
Mutual labels:  rxjava, rxandroid
Rxblur
用RxJava处理和操作高斯模糊效果的简单用例。
Stars: ✭ 541 (+446.46%)
Mutual labels:  rxjava, rxandroid
Rxmarkdown
📠Markdown for Android, supports TextView && EditText (Live Preview), supports code high light.
Stars: ✭ 714 (+621.21%)
Mutual labels:  rxjava, rxandroid
Rxbluetooth
Android reactive bluetooth
Stars: ✭ 405 (+309.09%)
Mutual labels:  rxjava, rxandroid
Kotlin Life
App界的一股清流 音视频vr应有尽有 完全按照Material design规范设计的App (written with java and Kotlin)
Stars: ✭ 864 (+772.73%)
Mutual labels:  rxjava, rxandroid
Swipe
👉 detects swipe events on Android
Stars: ✭ 324 (+227.27%)
Mutual labels:  rxjava, rxandroid
Freezer
A simple & fluent Android ORM, how can it be easier ? RxJava2 compatible
Stars: ✭ 326 (+229.29%)
Mutual labels:  rxjava, rxandroid
Elephant
Elephant is PHPHub Community Android unofficial client, base on Material Design + MVP+RxJava+Retrofit .
Stars: ✭ 949 (+858.59%)
Mutual labels:  rxjava, rxandroid
Todo
To-Do application written on Kotlin with RxJava and Dagger 2.
Stars: ✭ 61 (-38.38%)
Mutual labels:  rxjava, rxandroid

Reptar

Roaring RxJava. A collection of useful RxJava 2.X classes.

Build Status

Gradle Dependency

Add the jitpack url to the project:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

then, in your app build.gradle

dependencies {
    compile "com.github.Commit451.Reptar:reptar:latest.version.here"
    //for Retrofit support
    compile "com.github.Commit451.Reptar:reptar-retrofit:latest.version.here"
    //for Kotlin support
    compile "com.github.Commit451.Reptar:reptar-kotlin:latest.version.here"
}

Usage

Usage can be found in the sample project.

Observers

For instances where you only want to implement certain callbacks, use:

  • AdapterObserver
  • AdapterSingleObserver

Composable Observers

Often times, you want to subscribe to Observables and have certain rules surrounding the observers. For example, you may want to use a SingleObserver, but ignore any CancellationExceptions since your Activity or Fragment is probably destroyed when this exception is thrown. You could potentially override the Observer and do the check in the subclass. But, this can optional in tons of subclasses that all perform simple boolean checks.

ComposableSingleObserver and ComposableObserver make it simple to add checks on the success and failure of observers. For example:

someObservable
    .subscribe(new ComposableSingleObserver<Boolean>() {
        @Override
        public void success(Boolean aBoolean) {
            //do some success thing
        }

        @Override
        public void error(Throwable t) {
            //error block will never get CancellationExceptions
            onHandleError(t);
        }
    }.add(new CancellationFailureChecker()));

CancellationFailureChecker:

public class CancellationFailureChecker implements FailureChecker {

    @Override
    public boolean check(Throwable t) {
        return t instanceof CancellationException;
    }
}

You could also just create an abstract Observer that you use throughout the app that contains these rules so that you do not have to repeat them:

public abstract class CustomSingleObserver<T> extends ComposableSingleObserver<T> {

    public CustomSingleObserver() {
        add(new CancellationFailureChecker());
        //add other success and failure checks as desired
    }

}

See SuccessChecker and FailureChecker for more.

Avoiding Null

RxJava 2.x does not allow propagating null. Read more here. null is still something we may not want to have fall through into the onError block though. For instance, if we want to check if a value exists, we could say that null means no, and a valid value means yes.

As a replacement, we can use Optional. For example:

Optional<String> optional;
if (random.nextInt() % 2 == 0) {
    optional = new Optional<>("hi");
} else {
    optional = Optional.empty();
}
Single.just(optional)
        .subscribe(new ComposableSingleObserver<Optional<String>>() {
            @Override
            public void success(Optional<String> optional) {
                if (optional.hasValue()) {
                    Snackbar.make(root, "Has a optional", Snackbar.LENGTH_SHORT)
                            .show();
                } else {
                    Snackbar.make(root, "No optional", Snackbar.LENGTH_SHORT)
                            .show();
                }
            }

            @Override
            public void error(Throwable e) {
                //Note that an empty optional would not be an error
            }
        });

This is similar to an Optional in Guava

Retrofit Usage

For Retrofit, many times, you need to get the raw response from Retrofit, but you also want all non 2XX error codes to fall through to the onError(). For this, ResponseSingleObservable is perfect:

gitHub.contributors("square", "okhttp")
    .subscribe(new ResponseSingleObserver<List<Contributor>>() {
        @Override
        protected void responseSuccess(List<Contributor> contributors) {
            int responseCode = response().code();
            //do what you need to with the response
        }

        @Override
        public void error(Throwable e) {
            if (e instanceof HttpException) {
                //check the response code, do what you need to
            } else {
                //handle any other error
            }
        }
    });

Similarly, you can use ResponseFunction in replacement of Function to easily flatMap a optional without needing to worry about checking .isSuccessful() on the optional.

Kotlin Usage

Kotlin extensions allow for easy composition of Single and Observable for Android:

gitHub.contributors("jetbrains", "kotlin")
    .fromIoToMainThread()
    .subscribe(object : CustomSingleObserver<List<Contributor>>() {
        override fun success(t: List<Contributor>) {
            Snackbar.make(root, "It worked!", Snackbar.LENGTH_SHORT)
                    .show()
        }

        override fun error(t: Throwable) {
            onHandleError(t)
        }
    })

License

Copyright 2017 Commit 451

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].