UNPKG

airbridge-react-native-sdk

Version:

Airbridge SDK for React Native

40 lines (33 loc) 1.06 kB
import { NativeModules } from 'react-native' export type Native = { permission: { android: { accessFineLocation: () => void accessCoarseLocation: () => void } ios: { aceessTracking: () => void } } } export const createNativeDependency = () => ({ PermissionInteractor: NativeModules.PermissionInteractor, }) export const createNative = (): Native => { const { PermissionInteractor, } = createNativeDependency() return { permission: createInteractor(PermissionInteractor), } } const createInteractor = <Interactor extends object> (interactor: Interactor) => { return Object.assign(interactor, { ios: interactor, android: interactor, }) } // Originally, in order to write Unit-Testable code, the instance should not be exported // and instead be injected at the createDependency part using the createNative. // However, since this is a QA app, for convenience, the instance is exported. export const native = createNative()