Package dev.comfast.events
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 TypeMethodDescriptiondefault Stringon(String actionName, Consumer<AfterEvent<T>> listenerHandler)Utility method that creates listener listening to only one specific action.voidsubscribe(String listenerKey, EventListener<T> listener)Add new EventListener for given key.voidunsubscribe(String listenerKey)Removes Listener identified by its key
-
Method Details
-
subscribe
Add new EventListener for given key.- Parameters:
listenerKey- identifies given Listenerlistener- contain action to do before and after the event- Throws:
InvalidEventConfiguration- If key is already taken or is null or empty
-
unsubscribe
Removes Listener identified by its key- Parameters:
listenerKey- identifies given Listener
-
on
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 calledlistenerHandler- Action to do after call- Returns:
- listener key
-