import {TurboModuleRegistry} from 'react-native'; import type {TurboModule} from 'react-native'; /** * NativeBridgeModule规范接口 * TODO 适配方案: * 1. 生成在nodemodules内部,路径要稳定,单独chunk,建议不要被打包,直接作为JS或者Native代码调用 * 2. 代码生成方式, 生成一个Spec */ export interface Spec extends TurboModule { /** * 异步调用原生方法 * @param params 调用参数 * @returns 调用结果 */ callSync(params: string): string; /** * 同步调用原生方法 * @param params 调用参数 * @param callback 结果回调函数 */ call(params: string, callback: (res: string) => void): void; newApiEngine(): boolean; // //eventEmitter See: https://github.com/reactwg/react-native-new-architecture/discussions/144 //Note: The addListener and removeListeners implementations will be provided by React Native. addListener: (eventType: string) => void; removeListeners: (count: number) => void; } /** * 获取NativeBridgeModule实例 */ export default TurboModuleRegistry.get('VeLivePull') as Spec | null;