HATypedSubscription
public struct HATypedSubscription<ResponseType> where ResponseType : HADataDecodable
A subscription request which has a strongly-typed handler
-
Create a typed subscription
Declaration
Swift
public init(request: HARequest)
Parameters
request
The request to be issued to start the subscription
-
The request to be issued
Declaration
Swift
public var request: HARequest
-
Subscribe to one or all events on the event bus
Declaration
Swift
static func events( _ type: HAEventType ) -> HATypedSubscription<HAResponseEvent>
Parameters
type
The event type to subscribe to. Pass
.all
to subscribe to all events.Return Value
A typed subscriptions that can be sent via
HAConnection
-
Render a template and subscribe to live changes of the template
Declaration
Swift
static func renderTemplate( _ template: String, variables: [String: Any] = [:], timeout: Measurement<UnitDuration>? = nil ) -> HATypedSubscription<HAResponseRenderTemplate>
Parameters
template
The template to render
variables
The variables to provide to the template render on the server
timeout
Optional timeout for how long the template can take to render
Return Value
A typed subscriptions that can be sent via
HAConnection
-
Listen for state changes of all entities
This is a convenient version of listening to the
.stateChanged
event, but with parsed response values.Declaration
Swift
static func stateChanged() -> HATypedSubscription<HAResponseEventStateChanged>
Return Value
A typed subscriptions that can be sent via
HAConnection
-
Listen for compressed state changes of all entities
Declaration
Swift
static func subscribeEntities() -> HATypedSubscription<HACompressedStatesUpdates>
Return Value
A typed subscriptions that can be sent via
HAConnection