EventController

protocol EventController : Sendable

Controller for subscribing to events from a particular object.

  • Returns whether the given event type is supported by this controller.

    Declaration

    Swift

    func contains<E>(_ type: E.Type) -> Bool where E : Event
  • Subscribes to events of a given type E.

    Declaration

    Swift

    func subscribe<E>(_ type: E.Type) -> AnyPublisher<E, HomeError> where E : Event

    Return Value

    A Publisher that will publish events of the given type E.

  • Subscribes to all event types supported by the trait of a given type T.

    Declaration

    Swift

    func subscribe<T>(_ type: T.Type) -> AnyPublisher<any Event, HomeError> where T : Trait

    Return Value

    A Publisher that will publish the events.

  • Helper wrapper around subscribe(_:) that accepts a variabic parameter.

    Declaration

    Swift

    func subscribe(_ types: any Trait.Type...) -> AnyPublisher<any Event, HomeError>

    Return Value

    A Publisher that will publish the events.

  • Subscribes to all event types supported by the given traits.

    Declaration

    Swift

    func subscribe(_ types: [any Trait.Type]) -> AnyPublisher<any Event, HomeError>

    Return Value

    A Publisher that will publish the events.

  • Subscribes to all event types on all traits supported by the given device (if any).

    Note that the published events are of type AnyEvent and will need to be manually decoded into the appropriate concrete event type (as determined by the client) in order to be used.

    Declaration

    Swift

    func subscribeAll() -> AnyPublisher<AnyEvent, HomeError>

    Return Value

    A Publisher that will publish events from the device (if any).