Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two common needs #232

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Fix two common needs #232

wants to merge 4 commits into from

Conversation

zouyuefu
Copy link

Hi all,
there are two needs during the using of EventBus.

  1. Because of the complex lifecycle of activities, fragments, and so on, we offten need to register the same object again. But it's not allowed in EventBus.
  2. We have some tool class, only provide some static method, currently it's not support in EventBus.

I add these two functions, pls help have a review.

@william-ferguson-au
Copy link
Contributor

william-ferguson-au commented May 12, 2016

  1. You should be registering with eventBus at the start of your Activity/Fragments lifecycle and unsubscribing at the end of the lifecycle. Eg onCreate/onDestroy, onStart/onStop. Whatever makes most sense.

  2. Yet another good reason not to use static tool classes. Work out what your tool your tool class actually represents. Name it properly and create an instance of it. If you really only have a single instance of it and you absolutely have to make it available to every man and his dog and can't inject it, then make a static member to hold the instance. Once you start treating everything like an object you'll be surprised at the freedom you get.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants