Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(app): Refactor the application for simplicity #24

Open
edabe opened this issue Nov 28, 2024 · 0 comments
Open

refactor(app): Refactor the application for simplicity #24

edabe opened this issue Nov 28, 2024 · 0 comments

Comments

@edabe
Copy link
Owner

edabe commented Nov 28, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant