Skip to content

fix: refactor background observers and event listeners#312

Open
CaptainJeff wants to merge 2 commits intoagencyenterprise:masterfrom
coachcare:fix/refactor-background-observers
Open

fix: refactor background observers and event listeners#312
CaptainJeff wants to merge 2 commits intoagencyenterprise:masterfrom
coachcare:fix/refactor-background-observers

Conversation

@CaptainJeff
Copy link
Copy Markdown

@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
Copy Markdown
Author

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

@GGGava
Copy link
Copy Markdown
Contributor

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
Copy Markdown
Author

Hey @GGGava any update on reviewing this PR?

@GGGava
Copy link
Copy Markdown
Contributor

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
Copy Markdown

@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