Today, we are pleased to release EventBus 3. Previous versions of EventBus rejected to use annotations for performance reasons. Now, version 3 embraces annotations to improve performance. How does that make sense? Unfortunately, Android’s performance did not get any better. Reflection on annotations is still very bad compared to Desktop Java, even on Android 6 and ART. EventBus 3 resolves this problem by introducing a new annotation processor, which will index all annotations at build time. It generates a class containing all the data that would be expensive to get at run time. Build-time indexing makes EventBus 3 the fastest EventBus ever.
Switching to annotations is a major change and the API is not compatible with previous versions. Also, the package name changed to org.greenrobot.eventbus and the artifact is now org.greenrobot:eventbus. Like this you could even run EventBus 2 and 3 in your app in parallel. If you want to upgrade an existing app to EventBus 3, you need to change the imports to the new package and add @Subscribe annotations to your onEvent methods.
Another benefit of annotations is that each @Subscribe method can now individually configure additional parameters. Previously, priority and stickyness was configured on a class basis only, forcing all onEvent methods to share a single configuration. Now with EventBus 3, the @Subscribe offers additional parameters per method.
21 37 4