Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jacobsapps/4fcd7040e209ffddab451112f174e61d to your computer and use it in GitHub Desktop.

Select an option

Save jacobsapps/4fcd7040e209ffddab451112f174e61d to your computer and use it in GitHub Desktop.
.onAppear {
webSocketService.publisher
.decode(type: ThermostatState.self, decoder: decoder)
.receive(on: RunLoop.main)
.throttle(for: .seconds(0.25), scheduler: RunLoop.main, latest: true)
.sink(receiveCompletion: { print($0) },
receiveValue: { state in
if state.temperature > maxTemperature {
showOverheatWarning = true
} else {
withAnimation(.spring()) {
currentState = state
}
}
})
.store(in: &cancellables)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment