import { EmitterSubscription } from 'react-native'; import { EventEmitters } from './eventEmitters'; import { EventEmitterSchema } from './eventEmitters/types'; type MapOf = T extends EventEmitterSchema ? { [key in K]: T; } : never; type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; type EventEmittersMap = UnionToIntersection>; type EventKeys = keyof EventEmittersMap; type ParamOf = EventEmittersMap[K]['params']; /** * @interface BedrockEventEmitter * @description * 네이티브 플랫폼에서 발생하는 이벤트들을 처리하는 NativeEventEmitter를 토스에서 사용하는 형태에 맞게 정의한 인터페이스에요. * @property {(event: EventKeys, callback: (...params: ParamOf) => void) => EmitterSubscription} addListener - 이벤트 리스너를 추가하는 함수 * @property {(subscription: EmitterSubscription) => void} removeSubscription - 이벤트 구독을 제거하는 함수 */ interface BedrockEventEmitter { addListener(event: Event, callback: (...params: ParamOf) => void): EmitterSubscription; } /** * @kind constant * @name nativeEventEmitter * @description * 토스 네이티브 플랫폼에서 제공하는 react-native의 NativeEventEmitter instance에요. * @type {BedrockEventEmitter} */ export declare const nativeEventEmitter: BedrockEventEmitter; export {};