explaingit

greenrobot/eventbus

24,726JavaAudience · developerComplexity · 2/5DormantLicenseSetup · easy

TLDR

Lightweight Java library that lets different parts of an app send messages to each other without direct connections, using a publish-subscribe pattern.

Mindmap

mindmap
  root((EventBus))
    What it does
      Publish-subscribe messaging
      Decouples app components
      Handles thread switching
    How it works
      Post events from anywhere
      Subscribe to event types
      Automatic delivery
    Use cases
      Android screen updates
      Background task communication
      Cross-component messaging
    Tech stack
      Java
      Android
    Benefits
      Reduces boilerplate code
      Tiny library size
      Battle-tested at scale

Things people build with this

USE CASE 1

Update Android UI from background threads without manual thread management.

USE CASE 2

Send messages between Activities and Fragments without passing data through function parameters.

USE CASE 3

Notify multiple parts of an app when an event happens (e.g., user login, data refresh) without hardcoding dependencies.

USE CASE 4

Reduce callback chains and listener boilerplate in Java applications.

Tech stack

JavaAndroid

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you include the original copyright notice and license text.

In plain English

EventBus is a lightweight Java and Android library that lets different parts of an app communicate with each other without being directly connected. It follows a publish-subscribe pattern, one part of your app broadcasts ("posts") an event, and any other parts that have registered interest in that event type automatically receive it. This removes the need to pass data manually through complicated chains of function calls or callbacks. In practical terms, imagine you have an Android app with multiple screens (Activities and Fragments) and background tasks. Without EventBus, getting a background thread to update the user interface requires careful threading code. With EventBus, the background task posts an event, and any part of the app that subscribes to that event type receives it automatically, with EventBus handling the thread switching for you. You can control which thread the receiver runs on by specifying a thread mode. Android developers use EventBus to reduce boilerplate code and avoid bugs that arise from complex inter-component dependencies. The library is very small (about 60 kilobytes) and has been used in apps with over a billion installs. It is added to Android or Java projects via Maven or Gradle (standard Java build tools). Built in Java and licensed under Apache 2.0.

Copy-paste prompts

Prompt 1
Show me how to set up EventBus in an Android project and post an event from a background thread that updates the UI.
Prompt 2
How do I subscribe to an EventBus event in an Android Fragment and specify which thread the handler runs on?
Prompt 3
Give me a complete example of using EventBus to communicate between two Activities without passing data through intents.
Prompt 4
What are the thread modes in EventBus and when should I use each one?
Prompt 5
How do I unsubscribe from EventBus events to avoid memory leaks in Android?
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.