UNPKG

react-native-healthkit-bridge

Version:

A comprehensive React Native bridge for Apple HealthKit with TypeScript support, advanced authorization, and flexible data queries

67 lines (66 loc) 2.04 kB
/** * Example usage with full type safety * * This example shows the different ways to use the library: * 1. Full type safety (recommended) * 2. Using helper function * 3. Using string (less safe) */ export declare class TypeSafeUsageExample { private bridge; constructor(); /** * 1. USO COM TYPE SAFETY COMPLETA (RECOMENDADO) * * Para usar type safety completa, você precisa criar uma interface * que estenda HealthKitBridgeAPI (não HealthKitBridgeAPICompat) */ exampleWithFullTypeSafety(): Promise<void>; /** * 2. USING HELPER FUNCTION (RECOMMENDED FOR CURRENT USE) * * The getQuantityUnit function ensures you use the correct unit */ exampleWithHelperFunction(): Promise<void>; /** * 3. USING STRING (LESS SAFE, BUT FUNCTIONAL) * * You can use strings directly, but lose type safety */ exampleWithStringUnits(): Promise<void>; /** * 4. USING CONSTANTS (GOOD COMPROMISE) * * Using the exported constants for convenience */ exampleWithConstants(): Promise<void>; /** * 5. COMPLETE EXAMPLE OF AUTHORIZATION AND QUERY */ completeExample(): Promise<void>; } /** * SUMMARY OF TYPING OPTIONS: * * 1. ✅ Type Safety Completa (Ideal) * - Interface that forces QuantityTypeToUnit[T] * - TypeScript detects errors at compile time * - Requires custom implementation * * 2. ✅ Helper Function (Recommended for current use) * - getQuantityUnit() ensures correct unit * - Easy to use * - Type safety at runtime * * 3. ✅ Constants (Good compromise) * - HealthKitUnit.count, HealthKitUnit.beatsPerMinute, etc. * - Easy to remember * - Less prone to typing errors * * 4. ⚠️ Strings (Functional, but less safe) * - 'count', 'bpm', 'm', etc. * - Works, but no type checking * - Errors only detected at runtime * * RECOMMENDATION: Use the helper function getQuantityUnit() for the best balance between ease of use and type safety. */