# EventController

    protocol EventController : Sendable

Controller for subscribing to events from a particular object.
- `


  ### [contains(_:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/EventController#/s:13GoogleHomeSDK15EventControllerP8containsySbqd__mAA0D0Rd__lF)


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

  #### Declaration

  Swift

      func contains<E>(_ type: E.Type) -> Bool where E : https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Event.html

- `


  ### [subscribe(_:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/EventController#/s:13GoogleHomeSDK15EventControllerP9subscribey7Combine12AnyPublisherVyqd__AA0B5ErrorVGqd__mAA0D0Rd__lF)


  ` Subscribes to events of a given type `E`.

  #### Declaration

  Swift

      func subscribe<E>(_ type: E.Type) -> AnyPublisher<E, https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HomeError.html> where E : https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Event.html

  #### Return Value

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


  ### [subscribe(_:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/EventController#/s:13GoogleHomeSDK15EventControllerP9subscribey7Combine12AnyPublisherVyAA0D0_pAA0B5ErrorVGqd__mAA5TraitRd__lF)


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

  #### Declaration

  Swift

      func subscribe<T>(_ type: T.Type) -> AnyPublisher<any https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Event.html, https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HomeError.html> where T : https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Trait.html

  #### Return Value

  A `Publisher` that will publish the events.
- `


  ### [subscribe(_:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/EventController#/s:13GoogleHomeSDK15EventControllerP9subscribey7Combine12AnyPublisherVyAA0D0_pAA0B5ErrorVGAA5Trait_pXpd_tF)


  ` Helper wrapper around `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/EventController.html#/s:13GoogleHomeSDK15EventControllerP9subscribey7Combine12AnyPublisherVyqd__AA0B5ErrorVGqd__mAA0D0Rd__lF` that accepts a variabic parameter.

  #### Declaration

  Swift

      func subscribe(_ types: any https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Trait.html.Type...) -> AnyPublisher<any https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Event.html, https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HomeError.html>

  #### Return Value

  A `Publisher` that will publish the events.
- `


  ### [subscribe(_:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/EventController#/s:13GoogleHomeSDK15EventControllerP9subscribey7Combine12AnyPublisherVyAA0D0_pAA0B5ErrorVGSayAA5Trait_pXpGF)


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

  #### Declaration

  Swift

      func subscribe(_ types: [any https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Trait.html.Type]) -> AnyPublisher<any https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Event.html, https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HomeError.html>

  #### Return Value

  A `Publisher` that will publish the events.
- `


  ### [subscribeAll()](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/EventController#/s:13GoogleHomeSDK15EventControllerP12subscribeAll7Combine12AnyPublisherVyAA0iD0VAA0B5ErrorVGyF)


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

  Note that the published events are of type `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/AnyEvent.html` 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<https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/AnyEvent.html, https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HomeError.html>

  #### Return Value

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