Summary
In this chapter, we learned about the publish/subscribe messaging pattern used to communicate between decoupled entities on an Android application. This pattern must be applied to send event notifications or data to one or more Android component recipients.
Next, we introduced to the reader the EventBus
, an optimized open source library that delivers the publish-subscribe pattern for the Android platform and provides advanced features such as sticky events and asynchronous event delivery.
Following that, we learned how set up the library, how to model events, and how to dispatch events on the default Bus
. The Bus, a shared entity that receives the events, will act as a broker and proxy for the events to the final recipients that previously subscribed to them.
We took a detailed look at Eventbus
threadMode
feature of EventBus that allows us to define the thread in which the Bus
delivers the event to the subscriber. Hence, we were able to consume events in different threads (background...