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 : EventParameters
- event:
The event type to subscribe to. For example, Update.
- sourceObject:
The event source – usually the entity you are interested in.
nilto listen all events of this type that occur in the scene. - componentType:
The component type, or
nilfor all (for ComponentEvents).
Return Value
A Publisher for events of the specified type.