You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current behavior:
In the current implementation,index.ts connects to different sensors (pwr, fe, cad and hr) and handles events via onDetected and onData callbacks. Sensors constantly trigger detected and data events when connected and in range.
The app passes detected events to the HeartRateMode class via onDetectedHandler callback, which allows it to implement the logic that determines what to do when the sensor is detected or not.
In this case, if onDetectedHandler is not called within a set interval, HeartRateMode will clean itself up.
Improved approach:
Decouple the ANT+ connection logic from the index.ts file; there should be a new ANT connection class that implements this logic.
Modify the HeartRateMode behavior so that it only exposes a cleanup and onDataHandler methods.
Modify the ANT connection logic so that it leverages onDetected to monitor sensors and, after a set interval of inactivity, call cleanup from HeartRateMode.
Improve testing to cover the new refactoring.
The text was updated successfully, but these errors were encountered:
Current behavior:
In the current implementation,
index.ts
connects to different sensors (pwr
,fe
,cad
andhr
) and handles events viaonDetected
andonData
callbacks. Sensors constantly triggerdetected
anddata
events when connected and in range.The app passes
detected
events to theHeartRateMode
class viaonDetectedHandler
callback, which allows it to implement the logic that determines what to do when the sensor is detected or not.In this case, if
onDetectedHandler
is not called within a set interval,HeartRateMode
will clean itself up.Improved approach:
Decouple the ANT+ connection logic from the
index.ts
file; there should be a new ANT connection class that implements this logic.Modify the
HeartRateMode
behavior so that it only exposes acleanup
andonDataHandler
methods.Modify the ANT connection logic so that it leverages
onDetected
to monitor sensors and, after a set interval of inactivity, callcleanup
fromHeartRateMode
.Improve testing to cover the new refactoring.
The text was updated successfully, but these errors were encountered: