RxBus — an Event Bus Based on RxJava and Optimized for Android

What it’s all about

Event bus is a great solution that allows objects with different lifecycles and located in different layers of hierarchy to communicate.

Usage tips

We recommend obtaining a single instance of bus through injection or another appropriate mechanism. Alternatively, you may get a singleton like the following:

Bus bus = BusProvider.getInstance();
@Subscribe
public void onEvent(SomeEvent event) {
// TODO: Do something
}
CustomSubscriber<SomeEvent> customSubscriber = bus.obtainSubscriber(SomeEvent.class,
new Consumer<SomeEvent>() {
@Override
public void accept(SomeEvent someEvent) throws Exception {
// TODO: Do something
}
})
.withFilter(new Predicate<SomeEvent>() {
@Override
public boolean test(SomeEvent someEvent) throws Exception {
return "Specific message".equals(someEvent.message);
}
})
.withScheduler(Schedulers.trampoline());
bus.register(this);
bus.registerSubscriber(this, customSubscriber);
bus.unregister(this);
bus.post(new SomeEvent("Message"));
compile 'com.github.anadea:rxbus:1.0.1'

We build software and we do it right | Custom web and mobile development | https://anadea.info/

We build software and we do it right | Custom web and mobile development | https://anadea.info/