com.ekuefler.supereventbus.filtering
Annotation Type When
@Documented
@Inherited
@Target(value=METHOD)
public @interface When
Applies a filter to a Subscribe
-annotated method so that the
annotated method will be invoked only if the filter allows it. For example, the following filter
would only listen for events when the enclosing widget was visible:
class IsVisible implements EventFilter<HasVisibility, Object> {
@Override
public boolean accepts(HasVisibility handler, Object event) {
return handler.isVisible();
}
}
That filter could be applied to a handler method as follows:
@Subscribe @When(IsVisible.class)
void onMyEvent(MyEvent event) {
// Handle the event
}
Whenever MyEvent is fired, the handler method would be notified only if the widget containing it
was visible.
- Author:
- ekuefler@gmail.com (Erik Kuefler)
Required Element Summary |
Class<? extends EventFilter<?,?>>[] |
value
The list of filters that must be passed before this method is invoked. |
value
public abstract Class<? extends EventFilter<?,?>>[] value
- The list of filters that must be passed before this method is invoked. If multiple filters are
specified, they must all pass in order for the method to be invoked. The check is
short-circuiting, so later filters will not be invoked if earlier filters fail.
Copyright © 2013. All Rights Reserved.