    final class HistoryItemVisitor<Result> where Result : Sendable

    extension HistoryItemVisitor : Sendable, SendableMetatype

A visitor for history items.

Use this class to register handlers for specific event types and/or a default handler for
history items. When a history item is visited, the visitor will find the matching handler and
call it with the event payload and the history item.
- `


  ### [Handler](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/s:13GoogleHomeSDK18HistoryItemVisitorC7Handlera)


  ` The handler to be called when a history item is visited.

  #### Declaration

  Swift

      typealias Handler = (https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HistoryItem.html) throws -> Result?

  #### Return Value

  The result of the handling, or nil if the item should be ignored.
- `


  ### [init()](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/s:13GoogleHomeSDK18HistoryItemVisitorCACyxGycfc)


  ` Initializes a new history item visitor.

  #### Declaration

  Swift

      init()

- `


  ### [register(_:handler:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/s:13GoogleHomeSDK18HistoryItemVisitorC8register_7handleryqd__m_xSgqd___AA0dE0VtKctAA5EventRd__lF)


  ` Registers a handler for a specific event type.

  #### Declaration

  Swift

      func register<E>(_ eventType: E.Type, handler: @escaping (E, https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HistoryItem.html) throws -> Result?) where E : https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Event.html

  #### Parameters

  |---|---|
  | ` eventType ` | The type of event to register a handler for. |
  | ` handler ` | The handler to be called when a history item is visited. |

- `


  ### [register(_:handler:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/s:13GoogleHomeSDK18HistoryItemVisitorC8register_7handleryAA16StateChangeEventVyqd__Gm_xSgAH_AA0dE0VtKctAA5TraitRd__lF)


  ` Registers a handler for state changes to a specific `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Trait.html`.

  Any type conforming to the `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Trait.html` protocol can be monitored for state changes by
  registering for its corresponding `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/StateChangeEvent.html`.

  #### Declaration

  Swift

      func register<T>(_ eventType: https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/StateChangeEvent.html<T>.Type, handler: @escaping (https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/StateChangeEvent.html<T>, https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HistoryItem.html) throws -> Result?) where T : https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Trait.html

  #### Parameters

  |---|---|
  | ` eventType ` | The `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/StateChangeEvent.html` type to register a handler, where `T` is a `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Trait.html`. Example: `StateChangeEvent<StructureTrait>.self`. |
  | ` handler ` | The handler to be called when a matching history item is visited. |

- `


  ### [register(_:for:ignoreNilOldValue:handler:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/s:13GoogleHomeSDK18HistoryItemVisitorC8register_3for17ignoreNilOldValue7handleryAA16StateChangeEventVyqd__Gm_s7KeyPathCyqd__qd_0_GSbxSgAA0lO0Vyqd_0_G_AA0dE0VtKctAA5TraitRd__SQRd_0_s8SendableRd_0_r0_lF)


  ` Registers a handler for state changes to a specific `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Trait.html` property.

  The handler will only be called if the property actually changed.

  #### Declaration

  Swift

      func register<T, Value>(_ eventType: https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/StateChangeEvent.html<T>.Type, for keyPath: KeyPath<T, Value>, ignoreNilOldValue: Bool = false, handler: @escaping (https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/ValueChange.html<Value>, https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HistoryItem.html) throws -> Result?) where T : https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Trait.html, Value : Equatable, Value : Sendable

  #### Parameters

  |---|---|
  | ` eventType ` | The `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/StateChangeEvent.html` type to register a handler, where `T` is a `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Protocols/Trait.html`. |
  | ` ignoreNilOldValue ` | If true, the handler will not be called if the old value is nil. |
  | ` handler ` | The handler to be called when the property changes. |

- `


  ### [registerDefault(_:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/s:13GoogleHomeSDK18HistoryItemVisitorC15registerDefaultyyxSgAA0dE0VKcF)


  ` Registers a default handler for history items.

  This handler is used when a history item does not match any of the registered handlers.

  This is useful for handling events that are not covered by the registered handlers.

  #### Declaration

  Swift

      func registerDefault(_ handler: @escaping HistoryItemVisitor<Result>.https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor.html#/s:13GoogleHomeSDK18HistoryItemVisitorC7Handlera)

  #### Parameters

  |---|---|
  | ` handler ` | The handler to be called when a history item is visited. |

- `


  ### [visit(_:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/s:13GoogleHomeSDK18HistoryItemVisitorC5visityxSgAA0dE0VKF)


  ` Visits a single history item, returning the result of the most recently registered handler.
  Throws
  An error if the item cannot be visited.

  #### Declaration

  Swift

      func visit(_ item: https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HistoryItem.html) throws -> Result?

  #### Parameters

  |---|---|
  | ` item ` | The history item to be visited. |

  #### Return Value

  The result of the visit.
- `


  ### [visitAll(_:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/s:13GoogleHomeSDK18HistoryItemVisitorC8visitAllySayxGAA0dE0VKF)


  ` Visits a single history item, calling all registered handlers that match.
  Throws
  An error if the item cannot be visited or during `https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HistoryItem.html` payload decoding.

  #### Declaration

  Swift

      func visitAll(_ item: https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HistoryItem.html) throws -> [Result]

  #### Parameters

  |---|---|
  | ` item ` | The history item to be visited. |

  #### Return Value

  The results of the visits.
- `


  ### [collect(_:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/s:13GoogleHomeSDK18HistoryItemVisitorC7collectySayxGST_pAA0dE0V7ElementRts_XPKF)


  ` Visits a sequence of history items, calling all matching handlers for each item.
  Throws
  An error if any of the items cannot be visited.

  #### Declaration

  Swift

      func collect(_ items: any Sequence<https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HistoryItem.html>) throws -> [Result]

  #### Parameters

  |---|---|
  | ` items ` | The sequence of history items to be visited. |

  #### Return Value

  The results of the visits, or an empty array if no results were returned.
[## Available where \`Result\` == ()](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/Available%20where%20%60Result%60%20%3D%3D%20%28%29)

- `


  ### [visit(_:)](https://developers.home.google.com/reference/swift/GoogleHomeSDK/Classes/HistoryItemVisitor#/s:13GoogleHomeSDK18HistoryItemVisitorCAAytRszrlE5visityyST_pAA0dE0V7ElementRts_XPKF)


  ` Visits a sequence of history items.

  Available when `Result` is `Void`.
  Throws
  An error if any of the items cannot be visited.

  #### Declaration

  Swift

      func visit(_ items: any Sequence<https://developers.home.google.com/reference/swift/GoogleHomeSDK/Structs/HistoryItem.html>) throws

  #### Parameters

  |---|---|
  | ` items ` | The sequence of history items to be visited. |