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