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 Type
    Method
    Description
    default void
    after​(AfterEvent<T> event)
    Called after action. example implementation
    default void
    before​(BeforeEvent<T> event)
    Called before action. example implementation
  • Method Details

    • before

      default void before(BeforeEvent<T> event)
      Called before action. example implementation
      
       void 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

      default void after(AfterEvent<T> event)
      Called after action. example implementation
      
       class 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