Skip to content

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

License

Notifications You must be signed in to change notification settings

wongzy/RxEventBus

Repository files navigation

RxEventBus | 中文文档

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

Getting Started

  • Subscriber
  1. 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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages