Package dev.comfast.events
Interface EventListener<T>
- Type Parameters:
T- Type of context object that will be passed to listener.
public interface EventListener<T>
Event listener interface.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidafter(AfterEvent<T> event)Called after action. example implementationdefault voidbefore(BeforeEvent<T> event)Called before action. example implementation
-
Method Details
-
before
Called before action. example implementationvoid before(BeforeEvent<T> event) { if(e.actionName.equals("click")) { e.context.doSomething(); log.info("clicking on {}", e.actionParams[0]); } }- Parameters:
event- wraps all event data
-
after
Called after action. example implementationclass MyListener implements EventListener<T> { void after(AfterEvent<T> e) { if(e.isFailed()) { log.info("action '{}' failed: {}", e.actionName, e.error); // action 'click' failed: NoSuchElementException } else { log.info("got result: '{}' in {}", e.result, e.time); // got result: 'hello' in 43ms } } }- Parameters:
event- wraps all event data, including result and time
-