Skip to content

Commit

Permalink
feat(android): avoid warning by use DeviceEventEmitter
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Sep 7, 2023
1 parent 710dc71 commit b9487dd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit b9487dd

Please sign in to comment.