Bytecode
Bytecode

Reputation: 6591

Event bus versus Local broadcast Manager: which one is best

My app is heavily depended on Local broadcast ,for every activity invocation am invoking the broadcast registration method so is it good to move to any event bus.

Two primary concerns of using Local broadcast Manager.

  1. Every activity require the registration
  2. Registration method execution time(Around 10 actions are registered)

I think the event bus will improve overall execution and performance of my app.

Upvotes: 6

Views: 7199

Answers (3)

phnmnn
phnmnn

Reputation: 13240

EventBus FAQ

How is EventBus different to Android’s BroadcastReceiver/Intent system?

Unlike Android’s BroadcastReceiver/Intent system, EventBus uses standard Java classes as events and offers a more convenient API. EventBus is intended for a lot more uses cases where you wouldn’t want to go through the hassle of setting up Intents, preparing Intent extras, implementing broadcast receivers, and extracting Intent extras again. Also, EventBus comes with a much lower overhead.

Upvotes: 5

ישו אוהב אותך
ישו אוהב אותך

Reputation: 29783

afaik, there are some benefits using event-bus instead of LocalBroadcastManager:

  1. Code decoupling.
    By decoupling your code, you will minimize your class which formerly using LocalBroadcastManager. Simpler code less error and improve code readability.
  2. Ease of Maintenance.
    This somewhat related to no.1, decoupled code make it easy to maintained.
  3. Localizing error.
  4. Avoids complex and error-prone dependencies and life cycle issues.
  5. Avoid further bugs.

Upvotes: 7

dev.bmax
dev.bmax

Reputation: 10601

Most event bus libraries provide reflection-based registration which is less efficient than LocalBroadcastManager. The main reason for using the event bus would be coding ease.

Upvotes: 9

Related Questions