Return intial values in watch functions
This commit is contained in:
parent
367032ec7e
commit
df067d2c56
@ -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 {
|
||||||
|
Reference in New Issue
Block a user