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

fix: refactor background observers and event listeners #312

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CaptainJeff
Copy link

@CaptainJeff CaptainJeff commented May 18, 2023

Description

This is the work described in #233 where the background observers

Instead of creating four event listeners for every measurement type that you want to listen for in the background

NativeAppEventEmitter.addListener('healthKit:HeartRate:setup:success', callback)
NativeAppEventEmitter.addListener('healthKit:HeartRate:new', callback)
NativeAppEventEmitter.addListener('healthKit:HeartRate:setup:failure', callback)
NativeAppEventEmitter.addListener('healthKit:HeartRate:failure', callback)

We can now just create five event listeners for all measurements and pass the type as a parameter

NativeAppEventEmitter.addListener('healthKit:new', callback)
NativeAppEventEmitter.addListener('healthKit:failure', callback)
NativeAppEventEmitter.addListener('healthKit:enabled', callback)
NativeAppEventEmitter.addListener('healthKit:setup:failure', callback)
NativeAppEventEmitter.addListener('healthKit:setup:success', callback)
eventListener = eventEmitter.addListener(`healthKit:new`, (type) => {
   // Inspect the measurement type (workout, heartrate, etc...)
})

This PR also includes support for several new measuremetns including

  • BodyMass
  • BodyFatPercentage
  • BodyTemperature
  • BloodGlucose
  • BloodPressureDiastolic
  • BloodPressureSystolic
  • OxygenSaturation
  • RespiratoryRate

Fixes 233 - Unnecessary event listeners from being created

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have checked my code and corrected any misspellings

@CaptainJeff
Copy link
Author

@GGGava let me know if you have any questions about this PR

@GGGava
Copy link
Collaborator

GGGava commented Jun 29, 2023

Hey @CaptainJeff thank you for your PR, I will take a look at it soon, sorry for the delay

@GGGava GGGava self-assigned this Jun 29, 2023
@CaptainJeff
Copy link
Author

Hey @GGGava any update on reviewing this PR?

@GGGava
Copy link
Collaborator

GGGava commented Aug 18, 2023

Hey @CaptainJeff sorry for not reviewing it yet. We are currently working on a major refactor of this library (no more objective-c 🚀 ). We will probably release it under a new major version, so I'm currently avoiding changes to the current API. I still haven't thought about the observers in the new version yet, but I'll get there shortly.

@brandon-austin-lark
Copy link

@GGGava can we get some eyes on this please?

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

Successfully merging this pull request may close these issues.

Discussion: Refactor background observers to use the same eventEmitter
3 participants