Skip to content

loongwind/RxBus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RxBus

RxJava实现的事件总线RxBus

###使用方法

module的build.gradle中加入:

    compile 'com.cm:rxbus:1.0'

####注册:

RxBus.getDefault().register(this);

####实现订阅方法:

  @Subscribe
  public void onEvent(String s) {
      //TODO something
  }

  @Subscribe
  public void onEvent(EventA eventA) {
      //TODO something
  }

  @Subscribe(code = 102)
  public void onEventWithCode(EventA eventA) {
      //TODO something
  }

  @Subscribe(code = 103, threadMode = ThreadMode.MAIN)
  public void onEventWithCodeAndThreadMode(EventA eventA) {
      //TODO something
  }

####发送事件:

RxBus.getDefault().post("123456");
RxBus.getDefault().post(new EventA());
RxBus.getDefault().post(102, new EventA());

####取消订阅:

RxBus.getDefault().unRegister(this);

About

RxJava实现的android事件总线RxBus

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages