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

Support bridgeless architecture lazy loaded functions #396

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

Conversation

andrewzey
Copy link

Description

Exports functions properly for bridgeless architecture that is default as of react native 0.76.0

Fixes #395

Type of change

  • Bug fix (non-breaking change which fixes an issue)

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

Copy link

@Ashalbulk Ashalbulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done!
Small adjustment:

import { Activities, Observers, Permissions, Units } from './src/constants'

const { AppleHealthKit } = require('react-native').NativeModules

export const HealthKit = {
  initHealthKit: AppleHealthKit.initHealthKit,
  isAvailable: AppleHealthKit.isAvailable,
  getBiologicalSex: AppleHealthKit.getBiologicalSex,
  getBloodType: AppleHealthKit.getBloodType,
  getDateOfBirth: AppleHealthKit.getDateOfBirth,
  getLatestWeight: AppleHealthKit.getLatestWeight,
  getWeightSamples: AppleHealthKit.getWeightSamples,
  saveWeight: AppleHealthKit.saveWeight,
  getLatestHeight: AppleHealthKit.getLatestHeight,
  getHeightSamples: AppleHealthKit.getHeightSamples,
  saveHeight: AppleHealthKit.saveHeight,
  getLatestWaistCircumference: AppleHealthKit.getLatestWaistCircumference,
  getWaistCircumferenceSamples: AppleHealthKit.getWaistCircumferenceSamples,
  saveWaistCircumference: AppleHealthKit.saveWaistCircumference,
  getLatestPeakFlow: AppleHealthKit.getLatestPeakFlow,
  getPeakFlowSamples: AppleHealthKit.getPeakFlowSamples,
  savePeakFlow: AppleHealthKit.savePeakFlow,
  saveLeanBodyMass: AppleHealthKit.saveLeanBodyMass,
  getLatestBmi: AppleHealthKit.getLatestBmi,
  getBmiSamples: AppleHealthKit.getBmiSamples,
  saveBmi: AppleHealthKit.saveBmi,
  getLatestBodyFatPercentage: AppleHealthKit.getLatestBodyFatPercentage,
  getBodyFatPercentageSamples: AppleHealthKit.getBodyFatPercentageSamples,
  getLatestLeanBodyMass: AppleHealthKit.getLatestLeanBodyMass,
  getLeanBodyMassSamples: AppleHealthKit.getLeanBodyMassSamples,
  getStepCount: AppleHealthKit.getStepCount,
  getSamples: AppleHealthKit.getSamples,
  getAnchoredWorkouts: AppleHealthKit.getAnchoredWorkouts,
  getDailyStepCountSamples: AppleHealthKit.getDailyStepCountSamples,
  saveSteps: AppleHealthKit.saveSteps,
  saveWalkingRunningDistance: AppleHealthKit.saveWalkingRunningDistance,
  getDistanceWalkingRunning: AppleHealthKit.getDistanceWalkingRunning,
  getDailyDistanceWalkingRunningSamples: AppleHealthKit.getDailyDistanceWalkingRunningSamples,
  getDistanceCycling: AppleHealthKit.getDistanceCycling,
  getDailyDistanceCyclingSamples: AppleHealthKit.getDailyDistanceCyclingSamples,
  getFlightsClimbed: AppleHealthKit.getFlightsClimbed,
  getDailyFlightsClimbedSamples: AppleHealthKit.getDailyFlightsClimbedSamples,
  getEnergyConsumedSamples: AppleHealthKit.getEnergyConsumedSamples,
  getProteinSamples: AppleHealthKit.getProteinSamples,
  getFiberSamples: AppleHealthKit.getFiberSamples,
  getTotalFatSamples: AppleHealthKit.getTotalFatSamples,
  saveFood: AppleHealthKit.saveFood,
  saveWater: AppleHealthKit.saveWater,
  getWater: AppleHealthKit.getWater,
  saveHeartRateSample: AppleHealthKit.saveHeartRateSample,
  getWaterSamples: AppleHealthKit.getWaterSamples,
  getHeartRateSamples: AppleHealthKit.getHeartRateSamples,
  getRestingHeartRate: AppleHealthKit.getRestingHeartRate,
  getWalkingHeartRateAverage: AppleHealthKit.getWalkingHeartRateAverage,
  getActiveEnergyBurned: AppleHealthKit.getActiveEnergyBurned,
  getBasalEnergyBurned: AppleHealthKit.getBasalEnergyBurned,
  getAppleExerciseTime: AppleHealthKit.getAppleExerciseTime,
  getAppleStandTime: AppleHealthKit.getAppleStandTime,
  getVo2MaxSamples: AppleHealthKit.getVo2MaxSamples,
  getBodyTemperatureSamples: AppleHealthKit.getBodyTemperatureSamples,
  getBloodPressureSamples: AppleHealthKit.getBloodPressureSamples,
  getRespiratoryRateSamples: AppleHealthKit.getRespiratoryRateSamples,
  getHeartRateVariabilitySamples: AppleHealthKit.getHeartRateVariabilitySamples,
  getHeartbeatSeriesSamples: AppleHealthKit.getHeartbeatSeriesSamples,
  getRestingHeartRateSamples: AppleHealthKit.getRestingHeartRateSamples,
  getBloodGlucoseSamples: AppleHealthKit.getBloodGlucoseSamples,
  getCarbohydratesSamples: AppleHealthKit.getCarbohydratesSamples,
  saveBloodGlucoseSample: AppleHealthKit.saveBloodGlucoseSample,
  saveCarbohydratesSample: AppleHealthKit.saveCarbohydratesSample,
  deleteBloodGlucoseSample: AppleHealthKit.deleteBloodGlucoseSample,
  deleteCarbohydratesSample: AppleHealthKit.deleteCarbohydratesSample,
  getSleepSamples: AppleHealthKit.getSleepSamples,
  getInfo: AppleHealthKit.getInfo,
  getMindfulSession: AppleHealthKit.getMindfulSession,
  saveMindfulSession: AppleHealthKit.saveMindfulSession,
  getWorkoutRouteSamples: AppleHealthKit.getWorkoutRouteSamples,
  saveWorkout: AppleHealthKit.saveWorkout,
  getAuthStatus: AppleHealthKit.getAuthStatus,
  getLatestBloodAlcoholContent: AppleHealthKit.getLatestBloodAlcoholContent,
  getBloodAlcoholContentSamples: AppleHealthKit.getBloodAlcoholContentSamples,
  saveBloodAlcoholContent: AppleHealthKit.saveBloodAlcoholContent,
  getDistanceSwimming: AppleHealthKit.getDistanceSwimming,
  getDailyDistanceSwimmingSamples: AppleHealthKit.getDailyDistanceSwimmingSamples,
  getOxygenSaturationSamples: AppleHealthKit.getOxygenSaturationSamples,
  getElectrocardiogramSamples: AppleHealthKit.getElectrocardiogramSamples,
  saveBodyFatPercentage: AppleHealthKit.saveBodyFatPercentage,
  saveBodyTemperature: AppleHealthKit.saveBodyTemperature,
  getEnvironmentalAudioExposure: AppleHealthKit.getEnvironmentalAudioExposure,
  getHeadphoneAudioExposure: AppleHealthKit.getHeadphoneAudioExposure,
  getClinicalRecords: AppleHealthKit.getClinicalRecords,
  getActivitySummary: AppleHealthKit.getActivitySummary,
  getInsulinDeliverySamples: AppleHealthKit.getInsulinDeliverySamples,
  saveInsulinDeliverySample: AppleHealthKit.saveInsulinDeliverySample,
  deleteInsulinDeliverySample: AppleHealthKit.deleteInsulinDeliverySample,

  Constants: {
    Activities,
    Observers,
    Permissions,
    Units,
  },
}

module.exports = HealthKit

@andrewzey
Copy link
Author

@Ashalbulk Thanks for the review. I updated the code accordingly as well as my yarn patch and confirmed this works properly on React Native 0.76.0 bridgeless architecture both in development (using Xcode 16.1 running on iOS 18.1 simulator) as well as in production physically on a device (iPhone 15 Pro @ iOS 18.0.1 built via Bitrise using XCode 16.0)

@andrewzey andrewzey requested a review from Ashalbulk October 31, 2024 23:09
@willashley23
Copy link

Thanks for putting this PR up! Are there any blockers with merging this in? I rely on this library and would love to be able to update to the new arch!

@ben-edge
Copy link

Also relying on this to upgrade to 0.76! Would be great to get this in please.

@garywongzc
Copy link

Thanks for the PR! Is there anything preventing it from being merged? Would love to see this released soon. Thanks

@andrewzey
Copy link
Author

image

Copy link

@garywongzc garywongzc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@garywongzc
Copy link

Hey @GGGava @ruan-azevedo can you help us with this PR please? 🙏

garywongzc added a commit to garywongzc/lucid-react-native-health that referenced this pull request Dec 11, 2024
@ghure
Copy link

ghure commented Dec 14, 2024

Guys can you please merge this PR.

Copy link

@ghure ghure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good to me

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.

Doesn't work with new bridgeless architecture on 0.76.0
7 participants