Class CapableEventEmitter<T>

java.lang.Object
com.j3d.engine.react.events.EventEmitter
com.j3d.engine.react.events.CapableEventEmitter<T>
Type Parameters:
T - The type capableBroadcast(EventType, EventPayload) will return and the one that is expected. in the sense that if the type returned by CapableEventListener is the one matched by this, then the method immediately returns.
All Implemented Interfaces:
EventEmitterInterface
Direct Known Subclasses:
ErrorHandler

public class CapableEventEmitter<T> extends EventEmitter
What makes this different from your generic EventEmitter is that, this has runtime support for CapableEventListener, which returns a value. And further returns said value via capableBroadcast(EventType, EventPayload)
Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • typeToken

      private final Class<T> typeToken
  • Constructor Details

    • CapableEventEmitter

      public CapableEventEmitter(@NotNull Class<T> typeToken)
      Instantiates a new CapableEventEmitter bound to a specific runtime type.
      Parameters:
      typeToken - The class literal representing type T.
  • Method Details

    • capableBroadcast

      @Nullable @Contract(pure=true) public <K> Pair<CapableEventListener<T>, T> capableBroadcast(@NotNull EventType eventType, @NotNull EventPayload<K> properties)
      Broadcasts an event to all registered listeners
      Type Parameters:
      K - The object held by the EventPayload.
      Parameters:
      eventType - The event type.
      properties - Properties to pass onto the listener.
      Returns:
      A pair containing the original listener and the return value by that listener, or null.