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

Allow registration of classes without any subscriptions #284

Open
veeti opened this issue Mar 27, 2016 · 3 comments
Open

Allow registration of classes without any subscriptions #284

veeti opened this issue Mar 27, 2016 · 3 comments

Comments

@veeti
Copy link

veeti commented Mar 27, 2016

For automatic registration in base classes where some defined children might not have any subscriptions. This could be a configuration value on the bus or a registerOptional method.

@eku
Copy link

eku commented Mar 28, 2016

👍

@greenrobot-team
Copy link
Collaborator

greenrobot-team commented Jul 4, 2016

Why not move the register call to an overridable method that you overwrite empty in the child classes that should not register to EventBus? Would make it much more clear which classes register and which not and void the performance overhead of searching for subscriber methods.

Something like:

public abstract class BaseClass {
    protected void registerEventBus() {
        EventBus.getDefault().register(this);
    }
}
public class ChildClass extends BaseClass {
    @Override
    protected void registerEventBus() {
        // do not register to EventBus
    };
}

-ut

@veeti
Copy link
Author

veeti commented Jul 4, 2016

Because I'm honestly just not interested in keeping track of which child class is registering on the bus and which is not. I want to add a subscription to any activity/fragment at any time and have it just work. Whatever tiny performance overhead this adds is worth the developer comfort.

If anyone else is looking for this, my current workaround is to add a subscription on a dummy class inside the base class.

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

No branches or pull requests

3 participants