import { NativeModulesProxy, EventEmitter, Subscription } from 'expo-modules-core'; // Import the native module. On web, it will be resolved to NekoTest.web.ts // and on native platforms to NekoTest.ts import NekoTest from './NekoTestModule'; import NekoTestView from './NekoTestView'; import { ChangeEventPayload, NekoTestViewProps } from './NekoTest.types'; // Get the native constant value. export const PI = NekoTest.PI; export function hello(): string { return NekoTest.hello(); } export async function setValueAsync(value: string) { return await NekoTest.setValueAsync(value); } export async function getPosts(parameters: any) { return await NekoTest.getPosts(parameters); } // For now the events are not going through the JSI, so we have to use its bridge equivalent. // This will be fixed in the stable release and built into the module object. // Note: On web, NativeModulesProxy.NekoTest is undefined, so we fall back to the directly imported implementation const emitter = new EventEmitter(NativeModulesProxy.NekoTest ?? NekoTest); export function addChangeListener(listener: (event: ChangeEventPayload) => void): Subscription { return emitter.addListener('onChange', listener); } export { NekoTestView, NekoTestViewProps, ChangeEventPayload };