mirror of
https://github.com/gosticks/go-hue-interface.git
synced 2025-10-16 11:45:35 +00:00
24 lines
428 B
Go
24 lines
428 B
Go
package hue
|
|
|
|
import "reflect"
|
|
|
|
// Monitor is a interface which is used for checking events
|
|
type Monitor struct {
|
|
CurrentState interface{}
|
|
Handler func(interface{})
|
|
}
|
|
|
|
func (m *Monitor) hasChanged(newState interface{}) bool {
|
|
return reflect.DeepEqual(m.CurrentState, newState)
|
|
}
|
|
|
|
func (m *Monitor) Update(newState interface{}) {
|
|
if m.hasChanged(newState) {
|
|
m.Handler(newState)
|
|
}
|
|
}
|
|
|
|
func (b *Bridge) AddMonitor() {
|
|
|
|
}
|