[Android] EventBus

EventBus is a publish/subscribe event bus optimized for Android.EventBus-Publish-Subscribe

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

  1. Define events:
  2. Prepare subscribers: Register your subscriber (in your onCreate or in a constructor):
  3. Declare your subscribing method:
  4. Post events:

Gradle:

 

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.

Leave a Reply

Your email address will not be published. Required fields are marked *