Today, I’ve released my another tiny project. It’s a very simple implementation of Event Bus with RxJava 2 under the hood. This library is compatible with Java 1.7 or higher. I didn’t use Java 1.8 or 1.9 because I wanted to make it compatible with Android apps.
You can use it as follows:
Bus bus = ReactiveBus.create();
Once, we created Event Bus object and our observer (or more precisely: disposable subscriber), we can start sending events:
We can also send some serializable data:
bus.send(Event.name("my another event with data").data(serializableObject).build());
All events, will be received by the consumer in
If we want to stop propagation of the events, we can just dispose observer like any RxJava subscription:
Actually, most of the work is done by RxJava itself. In this project, I just put a few pieces together and played around with them in unit tests.
With such kind of Event Bus implementation, we can create fluent, functional, reactive piplines of data flow in our apps.
You can include this tiny library in your project via Maven:
or via Gradle:
For more details, visit project repository on GitHub: https://github.com/pwittchen/ReactiveBus