Home

EventBus

EventBus is a software design pattern and component that facilitates publish-subscribe messaging within an application. It enables decoupled communication between producers, known as publishers, and consumers, known as subscribers, by routing events to interested listeners without requiring direct references.

An event is typically an object or message describing something that occurred. Components register as listeners

Common implementations include Google Guava's EventBus and GreenRobot's EventBus for Android. These libraries typically provide registration

EventBus patterns are used to decouple components in user interfaces, modular architectures, and plugin systems, where

Drawbacks include potential debugging complexity, difficulty tracing event flows, and risk of memory leaks if subscribers

Related concepts include the publish-subscribe pattern, message brokers, and reactive streams.

for
specific
event
types;
when
a
publisher
posts
an
event
to
the
bus,
the
bus
delivers
the
event
to
all
registered
subscribers
for
that
type.
Depending
on
the
implementation,
dispatching
can
be
synchronous
(in
the
publisher's
thread)
or
asynchronous
(via
a
thread
pool
or
dedicated
event
loop).
Some
systems
support
multiple
handlers,
prioritization,
and
sticky
events
that
are
delivered
to
late
subscribers.
and
unregistration
APIs,
and
a
convention
for
defining
handler
methods
(for
example,
detailing
which
event
type
they
handle).
components
should
not
depend
on
concrete
collaborators.
They
are
also
used
in
server-side
applications
to
decouple
internal
modules.
are
not
unregistered;
ordering
and
delivery
guarantees
may
be
weak
or
configurable.
In
distributed
systems,
in-process
EventBus
concepts
are
extended
using
external
message
brokers
for
cross-process
or
cross-service
communication.