# Implementing an Event Bus With RxJava - RxBus

DevFeed: [Implementing an Event Bus With RxJava - RxBus](<https://devfeed.tech/articles/implementing-an-event-bus-with-rxjava-rxbus-25264.md>)

Original publisher: [Read original article](<https://kau.sh/blog/implementing-an-event-bus-with-rxjava-rxbus/>)

Author: Kaushik Gopal

Published: 2014-12-24T07:00:00Z

Content type: tutorial

Language: en

Sources: [Kaushik Gopal's Site](<https://devfeed.tech/sources/kaushik-gopal-s-site.md>)

Topics: [RxJava](<https://devfeed.tech/topics/rxjava.md>), [Development](<https://devfeed.tech/topics/development.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Android](<https://devfeed.tech/topics/android.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [code](<https://devfeed.tech/tags/code.md>), [decoupling](<https://devfeed.tech/tags/decoupling.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [events](<https://devfeed.tech/tags/events.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [observable](<https://devfeed.tech/tags/observable.md>), [rxjava](<https://devfeed.tech/tags/rxjava.md>)

## AI overview

A three-part tutorial that explains event buses through the Observer and publish-subscribe patterns, then describes implementing an event bus with RxJava for Android. It presents RxBus as a simple approach rather than a standalone library.

## Source excerpt

This post has three parts: quick primer on what an event bus is implementing the event bus with RxJava parting thoughts on this approach "RxBus" is not going to be a library. Implementing an event bus with RxJava is so ridiculously easy that it doesn't warrant the bloat of an independent library. Part 1: What is an event bus? # Let's talk about two concepts that seem similar: the Observer pattern and the Pub-sub pattern. Observer pattern ## This is a pattern of development in which your class or primary object (known as the Observable) notifies other interested classes or objects (known as Observers) with relevant information (events). Pub-sub pattern ## The objective of the pub-sub pattern is exactly the same as the Observer pattern viz. you want some other class to know of certain events taking place. There's an important semantic difference between the Observer and Pub-sub patterns though: in the pub-sub pattern the focus is on "broadcasting" messages outside. The Observable here doesn't want to know who the events are going out to, just that they've gone out. In other words the Observable (a.k.a Publisher) doesn't want to know who the Observers (a.k.a Subscribers) are. Why the anonymity? ## It allows for this thing called "decoupling", which is a good word in computer programming. You want to keep coupling as low as possible in your design. Typically, you would expect the publisher to have direct knowledge of each of the many subscribers that it needs to notify, so it can go about notifying each of them, once the "event" or message is ready. But with an event bus, the publisher is relieved of such duties and this independence helps, because the publisher and subscriber need not have logic coded in them that establish the dependencies between the two. In other words "consciously decouple" your code whenever you can*. How the anonymity? ## Ok, so a natural question with the pub-sub pattern is: how do you actually achieve that anonymity between publisher and subscr