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
requestThe 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
typeThe event type to subscribe to. Pass
.allto 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
templateThe template to render
variablesThe variables to provide to the template render on the server
timeoutOptional 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
.stateChangedevent, 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(data: [String : Any]) -> HATypedSubscription<HACompressedStatesUpdates>Parameters
dataThe data passed to connection request
Return Value
A typed subscriptions that can be sent via
HAConnection
View on GitHub