import { NativeEventEmitter, NativeModule } from 'react-native'
import { RNVntelCCCD } from '../native'
export const VntelEmitter = RNVntelCCCD as NativeModule
const EventEmitter = new NativeEventEmitter(VntelEmitter)

type AndroidEvent = 
    | 'MRZ_RESULT_ID_NUMBER'

type IOSEvent = 
    | 'MRZ_RESULT_ID_NUMBER_EXTRA'

export type VntelEvent = AndroidEvent | IOSEvent

function onDataChange(fn: (data: { event: VntelEvent }) => any) {
    return EventEmitter.addListener('ScanEvent', (data: { event: VntelEvent }) => {
      // here we can add extra params, if needed
      fn(data)
    })
}

export default {
    onDataChange
}