MCPcopy
hub / github.com/greenrobot/EventBus

github.com/greenrobot/EventBus @V3.3.1 sqlite

repository ↗ · DeepWiki ↗ · release V3.3.1 ↗
696 symbols 1,730 edges 97 files 82 documented · 12%
README

EventBus

EventBus is a publish/subscribe event bus for Android and Java.

Build Status Follow greenrobot on Twitter

EventBus...

  • simplifies the communication between components
    • decouples event senders and receivers
    • performs well with Activities, Fragments, and background threads
    • avoids complex and error-prone dependencies and life cycle issues
  • makes your code simpler
  • is fast
  • is tiny (~60k jar)
  • is proven in practice by apps with 1,000,000,000+ installs
  • has advanced features like delivery threads, subscriber priorities, etc.

EventBus in 3 steps

  1. Define events:

    java public static class MessageEvent { /* Additional fields if needed */ }

  2. Prepare subscribers: Declare and annotate your subscribing method, optionally specify a thread mode:

    java @Subscribe(threadMode = ThreadMode.MAIN) public void onMessageEvent(MessageEvent event) {/* Do something */}; Register and unregister your subscriber. For example on Android, activities and fragments should usually register according to their life cycle:

```java @Override public void onStart() { super.onStart(); EventBus.getDefault().register(this); }

@Override
public void onStop() {
    super.onStop();
    EventBus.getDefault().unregister(this);
}
```
  1. Post events:

java EventBus.getDefault().post(new MessageEvent());

Read the full getting started guide.

There are also some examples.

Note: we highly recommend the EventBus annotation processor with its subscriber index. This will avoid some reflection related problems seen in the wild.

Add EventBus to your project

Available on Maven Central.

Android projects:

implementation("org.greenrobot:eventbus:3.3.1")

Java projects:

implementation("org.greenrobot:eventbus-java:3.3.1")
<dependency>
    <groupId>org.greenrobot</groupId>
    <artifactId>eventbus-java</artifactId>
    <version>3.3.1</version>
</dependency>

R8, ProGuard

If your project uses R8 or ProGuard this library ships with embedded rules.

Homepage, Documentation, Links

For more details please check the EventBus website. Here are some direct links you may find useful:

Features

Documentation

Changelog

FAQ

License

Copyright (C) 2012-2021 Markus Junginger, greenrobot (https://greenrobot.org)

EventBus binaries and source code can be used according to the Apache License, Version 2.0.

Other projects by greenrobot

ObjectBox (GitHub) is a new superfast object-oriented database.

Essentials is a set of utility classes and hash functions for Android & Java projects.

Extension points exported contracts — how you extend this code

Poster (Interface)
Posts events. @author William Ferguson [7 implementers]
EventBus/src/org/greenrobot/eventbus/Poster.java
MyEventInterface (Interface)
(no doc) [1 implementers]
EventBusTestJava/src/main/java/org/greenrobot/eventbus/EventBusInheritanceDisabledTest.java
RunnableEx (Interface)
Like Runnable, but the run method may throw an exception. [10 implementers]
EventBus/src/org/greenrobot/eventbus/util/AsyncExecutor.java
MyEventInterfaceExtended (Interface)
(no doc) [1 implementers]
EventBusTestJava/src/main/java/org/greenrobot/eventbus/EventBusInheritanceDisabledTest.java
Logger (Interface)
(no doc) [7 implementers]
EventBus/src/org/greenrobot/eventbus/Logger.java
MyEventInterface (Interface)
(no doc) [1 implementers]
EventBusTestJava/src/main/java/org/greenrobot/eventbus/EventBusInheritanceTest.java
MainThreadSupport (Interface)
Interface to the "main" thread, which can be whatever you like. Typically on Android, Android's main thread is used. [2 …
EventBus/src/org/greenrobot/eventbus/MainThreadSupport.java
MyEventInterfaceExtended (Interface)
(no doc) [1 implementers]
EventBusTestJava/src/main/java/org/greenrobot/eventbus/EventBusInheritanceTest.java

Core symbols most depended-on inside this repo

register
called by 102
EventBus/src/org/greenrobot/eventbus/EventBus.java
get
called by 34
EventBus/src/org/greenrobot/eventbus/Logger.java
postSticky
called by 25
EventBus/src/org/greenrobot/eventbus/EventBus.java
unregister
called by 23
EventBus/src/org/greenrobot/eventbus/EventBus.java
log
called by 20
EventBus/src/org/greenrobot/eventbus/Logger.java
builder
called by 15
EventBus/src/org/greenrobot/eventbus/EventBus.java
toString
called by 13
EventBus/src/org/greenrobot/eventbus/EventBus.java
hasSubscriberForEvent
called by 11
EventBus/src/org/greenrobot/eventbus/EventBus.java

Shape

Method 526
Class 157
Interface 12
Enum 1

Languages

Java100%

Modules by API surface

EventBusPerformance/src/org/greenrobot/eventbusperf/testsubject/PerfTestEventBus.java51 symbols
EventBusTestJava/src/main/java/org/greenrobot/eventbus/EventBusOrderedSubscriptionsTest.java34 symbols
EventBus/src/org/greenrobot/eventbus/EventBus.java33 symbols
EventBusTestJava/src/main/java/org/greenrobot/eventbus/EventBusBasicTest.java32 symbols
EventBusPerformance/src/org/greenrobot/eventbusperf/testsubject/PerfTestOtto.java29 symbols
EventBusTestJava/src/main/java/org/greenrobot/eventbus/EventBusFallbackToReflectionTest.java22 symbols
EventBusTestJava/src/main/java/org/greenrobot/eventbus/EventBusStickyEventTest.java21 symbols
EventBusTestJava/src/main/java/org/greenrobot/eventbus/EventBusMultithreadedTest.java18 symbols
EventBus/src/org/greenrobot/eventbus/EventBusBuilder.java18 symbols
EventBusPerformance/src/org/greenrobot/eventbusperf/TestParams.java17 symbols
EventBusAnnotationProcessor/src/org/greenrobot/eventbus/annotationprocessor/EventBusAnnotationProcessor.java17 symbols
EventBusTestJava/src/main/java/org/greenrobot/eventbus/EventBusCancelEventDeliveryTest.java16 symbols

For agents

$ claude mcp add EventBus \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact