EventList manages a list of callbacks that can be invoked together.
Used for Unity-style events that can be configured in the editor (Unity or Blender).

Serialization:
EventLists are serializable - callbacks configured in Unity/Blender will work at runtime.
Mark fields with @serializable(EventList) for editor support.

Usage patterns:

  • Button click handlers
  • Animation events
  • Custom component callbacks
  • Scene loading events


Screenshot of a Unity component with an EventList field


Screenshot of a Blender component with an EventList field

// Define in your component
@serializable(EventList)
onClick: EventList = new EventList();

// Add listeners
this.onClick.addEventListener(() => console.log("Clicked!"));

// Invoke all listeners
this.onClick.invoke();
const onScore = new EventList<{ points: number }>();
onScore.addEventListener(data => console.log("Scored:", data.points));
onScore.invoke({ points: 100 });
  • CallInfo for individual callback configuration
  • Button for UI button events

Type Parameters

  • TArgs extends any = any

Implements

Constructors

  • Create a new EventList with the given callback methods. You can pass either CallInfo instances or functions directly.

    Type Parameters

    • TArgs extends unknown = any

    Parameters

    Returns EventList<TArgs>

    a new EventList instance with the given callback methods

Properties

isEventList: true

checked during instantiate to create a new instance

Accessors

  • get isInvoking(): boolean

    If the event is currently being invoked

    Returns boolean

  • get listenerCount(): number

    How many callback methods are subscribed to this event

    Returns number

Methods

  • Add a new event listener to this event

    Parameters

    • callback: (args: TArgs) => void

    Returns Function

    a function to remove the event listener

  • Invoke all the methods that are subscribed to this event

    Parameters

    • ...args: TArgs[]

      optional arguments to pass to the event listeners. These will be passed before any custom arguments defined in the CallInfo instances. So if you have a CallInfo with arguments and you also pass arguments to invoke, the arguments passed to invoke will take precedence over the CallInfo arguments.

    Returns boolean

    true if the event was successfully invoked, false if there are no listeners or if a circular invocation was detected

  • Remove all event listeners from this event. Use with caution! This will remove all listeners!

    Returns void

  • Remove an event listener from this event.

    Parameters

    Returns boolean

    true if the event listener was found and removed, false otherwise

  • set an event target to try invoke the EventTarget dispatchEvent when this EventList is invoked

    Parameters

    • key: string
    • target: object

    Returns void

  • Create a new EventList with the given callback methods. You can pass either CallInfo instances or functions directly.

    Parameters

    Returns EventList<any>

    a new EventList instance with the given callback methods

    const onClick = EventList.from(
    () => console.log("Clicked!"),
    new CallInfo(someObject, "someMethod", [arg1, arg2])
    );
    onClick.invoke();