diff --git a/src/index.ts b/src/index.ts index 7853133..9b889f0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { NativeEventEmitter } from 'react-native' +import { NativeEventEmitter, DeviceEventEmitter, Platform } from 'react-native' import type { DeviceEventEmitterStatic } from 'react-native' import RNLlama from './NativeRNLlama' import type { @@ -15,9 +15,14 @@ export { SchemaGrammarConverter, convertJsonSchemaToGrammar } const EVENT_ON_TOKEN = '@RNLlama_onToken' -const EventEmitter: NativeEventEmitter | DeviceEventEmitterStatic = +let EventEmitter: NativeEventEmitter | DeviceEventEmitterStatic +if (Platform.OS === 'ios') { // @ts-ignore - new NativeEventEmitter(RNLlama) + EventEmitter = new NativeEventEmitter(RNLlama) +} +if (Platform.OS === 'android') { + EventEmitter = DeviceEventEmitter +} export type TokenData = { token: string