EventBus is a publish/subscribe event bus optimized for Android.
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 (~50k jar)
- is proven in practice by apps with 100,000,000+ installs
- has advanced features like delivery threads, subscriber priorities, etc.
EventBus in 3 steps
- Define events:
 1public class MessageEvent { /* Additional fields if needed */ }
- Prepare subscribers: Register your subscriber (in your onCreate or in a constructor):
 1eventBus.register(this);
- Declare your subscribing method:
 12@Subscribepublic void onEvent(AnyEventType event) {/* Do something */};
- Post events:
 1eventBus.post(event);
Gradle:
| 1 | compile 'org.greenrobot:eventbus:3.0.0' | 
License
Copyright (C) 2012-2016 Markus Junginger, greenrobot (http://greenrobot.org)
EventBus binaries and source code can be used according to the Apache License, Version 2.0.
