Class TEventHandler<T>

  • Type Parameters:
    T - the template

    public final class TEventHandler<T>
    extends java.lang.Object
    This class for handling events and these subscribers.
    Author:
    kong
    • Constructor Summary

      Constructors 
      Constructor Description
      TEventHandler()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear all events and these handlers.
      java.lang.Object emit​(TEvent type, T... args)
      Emit an event with its parameters.
      void subscribe​(TEvent type, IEvent<T> event)
      Create a link between an event and its list of event handlers.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TEventHandler

        public TEventHandler()
    • Method Detail

      • subscribe

        public void subscribe​(TEvent type,
                              IEvent<T> event)
        Create a link between an event and its list of event handlers.
        Parameters:
        type - see TEvent
        event - see IEvent
      • emit

        public java.lang.Object emit​(TEvent type,
                                     T... args)
        Emit an event with its parameters.
        Parameters:
        type - see TEvent
        args - a list parameters of this event
        Returns:
        the event result (the response of its subscribers), see Object or null
      • clear

        public void clear()
        Clear all events and these handlers.