Return intial values in watch functions

This commit is contained in:
Elara 2021-08-24 22:17:34 -07:00
parent 0430ddcd30
commit 745b4bd37c

View File

@ -338,6 +338,11 @@ func (i *Device) WatchHeartRate() (<-chan uint8, error) {
return nil, err return nil, err
} }
out := make(chan uint8, 2) out := make(chan uint8, 2)
currentHeartRate, err := i.HeartRate()
if err != nil {
return nil, err
}
out <- currentHeartRate
go func() { go func() {
// For every event // For every event
for event := range ch { for event := range ch {
@ -366,6 +371,11 @@ func (i *Device) WatchBatteryLevel() (<-chan uint8, error) {
return nil, err return nil, err
} }
out := make(chan uint8, 2) out := make(chan uint8, 2)
currentBattLevel, err := i.BatteryLevel()
if err != nil {
return nil, err
}
out <- currentBattLevel
go func() { go func() {
// For every event // For every event
for event := range ch { for event := range ch {