UNPKG

1.38 kBTypeScriptView Raw
1import type { IWorkletEventHandler, ReanimatedEvent } from './commonTypes';
2/** Worklet to provide as an argument to `useEvent` hook. */
3export type EventHandler<Event extends object, Context extends Record<string, unknown> = never> = (event: ReanimatedEvent<Event>, context?: Context) => void;
4export type EventHandlerProcessed<Event extends object, Context extends Record<string, unknown> = never> = (event: Event, context?: Context) => void;
5export type EventHandlerInternal<Event extends object> = {
6 workletEventHandler: IWorkletEventHandler<Event>;
7};
8/**
9 * Lets you run a function whenever a specified native event occurs.
10 *
11 * @param handler - A function that receives an event object with event data -
12 * {@link EventHandler}.
13 * @param eventNames - An array of event names the `handler` callback will react
14 * to.
15 * @param rebuild - Whether the event handler should be rebuilt. Defaults to
16 * `false`.
17 * @returns A function that will be called when the event occurs -
18 * {@link EventHandlerProcessed}.
19 * @see https://docs.swmansion.com/react-native-reanimated/docs/advanced/useEvent
20 */
21export declare function useEvent<Event extends object, Context extends Record<string, unknown> = never>(handler: EventHandler<Event, Context>, eventNames?: string[], rebuild?: boolean): EventHandlerProcessed<Event, Context>;
22//# sourceMappingURL=useEvent.d.ts.map
\No newline at end of file