-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Comments
👍 |
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 |
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. |
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.The text was updated successfully, but these errors were encountered: