subscribe(to:on:_:)
Subscribes to an event type, optionally limited to events affecting a source entity or scene.
Declaration
func subscribe<E>(to event: E.Type, on sourceObject: (any EventSource)?, _ handler: @escaping (E) -> Void) -> EventSubscription where E : EventParameters
- event:
The event type to subscribe to. For example, Update or Didactivate.
- sourceObject:
An optional source for the event, such as an entity or a scene. Set to
nilto listen for all events of the event type within the view content. - handler:
A closure that runs when the
eventoccurs.
Return Value
An object that represents the subscription to this event stream.