All Projects → florent37 → Rxbus

florent37 / Rxbus

Licence: apache-2.0
Android reactive event bus that simplifies communication between Presenters, Activities, Fragments, Threads, Services, etc.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rxbus

Thirtyinch
a MVP library for Android favoring a stateful Presenter
Stars: ✭ 1,052 (+1231.65%)
Mutual labels:  rxjava, rxjava2, activity, fragment
Rxlifecycle
Rx binding of stock Android Activities & Fragment Lifecycle, avoiding memory leak
Stars: ✭ 131 (+65.82%)
Mutual labels:  rxjava, rxjava2, activity, fragment
ReactiveBus
🚍 Reactive Event Bus for JVM (1.7+) and Android apps built with RxJava 2
Stars: ✭ 17 (-78.48%)
Mutual labels:  bus, rxjava, event, rxjava2
Vertx Mqtt
Vert.x MQTT
Stars: ✭ 117 (+48.1%)
Mutual labels:  rxjava, reactive, rxjava2
Rxreactor
A Kotlin framework for a reactive and unidirectional RxJava application architecture
Stars: ✭ 19 (-75.95%)
Mutual labels:  rxjava, reactive, rxjava2
Rxjava2 Operators Magician
你用不惯 RxJava,只因缺了这把钥匙 🔑 You are not used to RxJava, just because of the lack of this key.
Stars: ✭ 868 (+998.73%)
Mutual labels:  rxjava, reactive, rxjava2
rxjava2-http
Transmit RxJava2 Flowable over http with non-blocking backpressure
Stars: ✭ 19 (-75.95%)
Mutual labels:  reactive, rxjava, rxjava2
Rxgps
Finding current location cannot be easier on Android !
Stars: ✭ 307 (+288.61%)
Mutual labels:  rxjava, reactive, rxjava2
Rxfirebase
Rxjava 2.0 wrapper on Google's Android Firebase library.
Stars: ✭ 509 (+544.3%)
Mutual labels:  rxjava, reactive, rxjava2
Androidall
Android 程序员需要掌握的技术栈:数据结构算法、程序架构、设计模式、性能优化、插件化、热更新、Kotlin、NDK、Jetpack,以及常用的开源框架源码分析如 Flutter、Router、RxJava、Glide、LeakCanary、Dagger2、Retrofit、OkHttp、ButterKnife 等
Stars: ✭ 849 (+974.68%)
Mutual labels:  rxjava, fragment
Spring Reactive Sample
Spring 5 Reactive playground
Stars: ✭ 867 (+997.47%)
Mutual labels:  rxjava, rxjava2
Rx.observe
Transform any method to an Rx Observable ! (VIPER)
Stars: ✭ 34 (-56.96%)
Mutual labels:  rxjava, rxjava2
Fcfrtmvp
🔥FcfrtMvp+RxHttp+RxJava(Kotlin和JAVA共用完美支持)支持一键创建MVP项目,框架简约风格及详细注释,欢迎 star or fork!
Stars: ✭ 23 (-70.89%)
Mutual labels:  rxjava, rxjava2
Rxjavafiberinterop
Library for interoperation between RxJava 3 and Project Loom's Fibers.
Stars: ✭ 19 (-75.95%)
Mutual labels:  rxjava, reactive
Rxdownloader
- Reactive Extension Library for Android to download files
Stars: ✭ 40 (-49.37%)
Mutual labels:  reactive, rxjava2
Rxschedulerrule
Simple JUnit rule for overriding RxJava/RxAndroid schedulers during unit tests
Stars: ✭ 35 (-55.7%)
Mutual labels:  rxjava, rxjava2
Mvvmhabit
goldze: 本人喜欢尝试新的技术,以后发现有好用的东西,我将会在企业项目中实战,没有问题了就会把它引入到MVVMHabit中,一直维护着这套框架,谢谢各位朋友的支持。如果觉得这套框架不错的话,麻烦点个 star,你的支持则是我前进的动力!
Stars: ✭ 6,789 (+8493.67%)
Mutual labels:  rxjava, rxjava2
Rxjava Android Samples
Learning RxJava for Android by example
Stars: ✭ 7,520 (+9418.99%)
Mutual labels:  rxjava, reactive
Viewtooltip
A fluent tooltip for Android
Stars: ✭ 1,029 (+1202.53%)
Mutual labels:  activity, fragment
Bigbang
Android base project used by Xmartlabs team
Stars: ✭ 47 (-40.51%)
Mutual labels:  rxjava, rxjava2

RxBus

Android reactive event bus that simplifies communication between Presenters, Activities, Fragments, Threads, Services, etc.

Android app on Google Play

Download

Buy Me a Coffee at ko-fi.com

Download

dependencies {
    compile 'com.github.florent37:rxbus:1.0.0'
}

RxBus in 2 steps

  1. Prepare subscribers
RxBus.getDefault()
                .onEvent("eventName")
                .doOnSubscribe(disposables::add)
                .subscribe(s -> {
                     //called when an event "eventName" is posted      
                });
  1. Post event
RxBus.getDefault().post("eventName");

Messages types

rxbus.post(String) <-> rxbus.onEvent(String)

rxbus.post(userInstance) <-> rxbus.onEvent(User.class)

Extended Bus

  1. Extend RxBus for a specific usage
public class RxBusUser extends RxBus {

    private static RxBusUser instance = new RxBusUser();

    public static RxBusUser getInstance() {
        return instance;
    }

    public Observable<User> onUserChanged(){
        return super.onEvent(User.class);
    }

    public void userChanged(User user){
        super.post(user);
    }

    public void displayUser(boolean display){
        super.post(new DisplayUserCustomEvent(display));
    }

    public Observable<Boolean> onDisplayUser(){
        return super.onEvent(DisplayUserCustomEvent.class)
                .map(DisplayUserCustomEvent::displayUser);
    }

    protected class DisplayUserCustomEvent {

        public boolean displayUser;

        public DisplayUserCustomEvent(boolean displayUser) {
            this.displayUser = displayUser;
        }

        public boolean displayUser() {
            return displayUser;
        }
    }

}
  1. Register to user change
final RxBusUser rxBusUser = RxBusUser.getInstance();

rxBusUser.onUserChanged()
        .doOnSubscribe(disposables::add)
        .subscribe(user -> display(user));
  1. Post the user
RxBusUser.getInstance().userChanged(user);

Unsubscribe

  1. don't forget to add the disposable to a CompositeDisposable .doOnSubscribe(compositeDisposable::add)

  2. OnDestroy should call compositeDisposable.clear()

Credits

Author: Florent Champigny http://www.florentchampigny.com/

Blog : http://www.tutos-android-france.com/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2017 Florent37, Inc.

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