EventBus
EventBus copied to clipboard
Do not throw on register if the registered class has no onEvent
This makes it easier to do the registration in a base class where some of the derived class may not subscribe to any event.
I would also like a flag to disable the exception, because of a very similiar reason then the above.
What I do is subscribe to a pointless 'dummy event' in my BaseActivity. Not elegant, but better than subscribing in every Activity that I derive from it.
Use case makes sense. Wonder if we can configure this behavior elegantly.
On the other hand you can wrap the registration with a try/catch and log it. it makes sense If you already know you might have a derived class with no event listeners.
Not sure if that should be implemented using #124 or some registration flags (planned for a future version). Against #124 speaks that it would not complain if the completely wrong object gets registered.
In JPA (Java Persistence API) we have the annotation @ExcludeSuperclassListeners. When a subclass is flagged with this annotation she becomes ignored. What do you think of this solution?
@RoxRicardo Sounds good, will think about it. Eventually there will be a single @Subscriber annotation to customize, so there might be a property for that, e.g. @Subscriber(ignoreNoSubscribers = true).
@greenrobot i'm interested in contribute, can you suggest some feature of backlog?
Has a proper solution for this issue been released?
@aneemtalukder You still have to make sure to have at least one method annotated with @Subscribe
before calling .register()
or EventBus will throw an exception. -ut
still no change? a configuration in the builder to ignore this error would be awesome