Interface SubscriberManager<T>

Type Parameters:
T - any class that will be passed to events
All Known Implementing Classes:
EventsManager

public interface SubscriberManager<T>
Allows to add/remove subscriber listeners.
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    on​(String actionName, Consumer<AfterEvent<T>> listenerHandler)
    Utility method that creates listener listening to only one specific action.
    void
    subscribe​(String listenerKey, EventListener<T> listener)
    Add new EventListener for given key.
    void
    unsubscribe​(String listenerKey)
    Removes Listener identified by its key
  • Method Details

    • subscribe

      void subscribe(String listenerKey, EventListener<T> listener)
      Add new EventListener for given key.
      Parameters:
      listenerKey - identifies given Listener
      listener - contain action to do before and after the event
      Throws:
      InvalidEventConfiguration - If key is already taken or is null or empty
    • unsubscribe

      void unsubscribe(String listenerKey)
      Removes Listener identified by its key
      Parameters:
      listenerKey - identifies given Listener
    • on

      default String on(String actionName, Consumer<AfterEvent<T>> listenerHandler)
      Utility method that creates listener listening to only one specific action.

      It is called after given action. Can be defined inline e.g.

      e.g.
      
       myManager.on("click", e -> { if(e.isFailed()) e.context.takeScreenshot(); });
       myManager.on("getText", e -> log.info("got text: '{}'", e.result));
       
      Parameters:
      actionName - only after this action listener will be called
      listenerHandler - Action to do after call
      Returns:
      listener key