RxEventBus

Introduction: A EventBus based on RxJava2, using Retention.CLASS annotation.
More: Author   ReportBugs   
Tags:

A EventBus based on RxJava2, using Retention.CLASS annotation.

Getting Started

  • Subscriber

  • register subscriber

@Override
    public void onStart() {
        super.onStart();
        RxEventBus.getDefault().register(this);
    }
  1. write Subscribe method, like this
@Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageHandle(String s) {
        mTextView.setText(s);
    }
  1. don't forget unregister when activity or others destroyed
@Override
    public void onDestroy() {
        super.onDestroy();
        RxEventBus.getDefault().unregister(this);
    }
  • Post
RxEventBus.getDefault().post(mEditText.getText().toString());

Of cause you can post any kind of message, not just String

Install

this project isn't pushed to maven, if you want to use it, just

git clone https://github.com/JoshuaRogue/RxEventBus.git

and copy module to your project.

It will be pushed to maven soon.

demo

Apps
About Me
GitHub: Trinea
Facebook: Dev Tools