Class Event<T>

java.lang.Object
net.fabricmc.fabric.api.event.Event<T>
Type Parameters:
T - The listener type.

public abstract class Event<T> extends Object
Base class for Event implementations.
See Also:
EventFactory
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected T
    The invoker field.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the invoker instance.
    abstract void
    register​(T listener)
    Register a listener to the event.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • invoker

      protected volatile T invoker
      The invoker field. This should be updated by the implementation to always refer to an instance containing all code that should be executed upon event emission.
  • Constructor Details

    • Event

      public Event()
  • Method Details

    • invoker

      public final T invoker()
      Returns the invoker instance.

      An "invoker" is an object which hides multiple registered listeners of type T under one instance of type T, executing them and leaving early as necessary.

      Returns:
      The invoker instance.
    • register

      public abstract void register(T listener)
      Register a listener to the event.
      Parameters:
      listener - The desired listener.