Thread mode
EventBus
, by default, delivers the event in the subscriber in the same thread where the sender posted the event. Although this delivery scheme might work for most use cases, such as events that perform Android UI changes, when a long operation is executed in the event callback, the subscriber might block the main thread and prevent the system from running the UI rendering in time and drop some UI frames as a result.
To cope with time-consuming operations that might happen during the event delivery, the EventBus
library allows us to define the Thread in which the Bus
will call to deliver the event to the subscriber (ThreadMode
).
There are four modes supported by EventBus
that we can use to control the event delivering behavior:
ThreadMode.POSTING ...
Get Asynchronous Android Programming - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.