Contents

publisher(for:on:componentType:)

Returns a Publisher for events of the specified type in a Scene.

Declaration

@MainActor @preconcurrency func publisher<E>(for event: E.Type, on sourceObject: (any EventSource)? = nil, componentType: (any Component.Type)?) -> Scene.Publisher<E> where E : Event

Parameters

  • event:

    The event type to subscribe to. For example, Update.

  • sourceObject:

    The event source – usually the entity you are interested in. nil to listen all events of this type that occur in the scene.

  • componentType:

    The component type, or nil for all (for ComponentEvents).

Return Value

A Publisher for events of the specified type.

See Also

Publishing and subscribing to events