I am looking at using the Guava EventBus in my application to distribute data (Doubles for example) from one or more data creators through to data consumer.
I know in my consumer class, I need to annotate my data handler with @Subscribe. Is there a way in which to make this subscription conditional? So for example
@Subscribe {newValue > 0.0} public void valueUpdated(Double newValue)
I could add the check within my valueUpdated method, but is there a way to stop the EventBus from dispatching values that my Subscriber is not interested in?
Is there a product similar to EventBus that may provide this sort of function?
Spring Expression Language (SpEL) may help.
Plus: after checking the EventBus, I think it's type-based dispatch, no way to apply condition-based dispatch. If you insist on using Expression Language, you could put it in subscriber as Louis comment. But Expression Language is designed for flexibility rather than speed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With