UNPKG

@daily-co/daily-react

Version:

Daily React makes it easier to integrate [@daily-co/daily-js](https://www.npmjs.com/package/@daily-co/daily-js) in React applications.

20 lines (19 loc) 1.42 kB
import { DailyEvent, DailyEventObject } from '@daily-co/daily-js'; type EnsureArray<T> = T extends DailyEvent ? [T] : T; type EventObjectsFor<T> = EnsureArray<T> extends (infer U)[] ? U extends DailyEvent ? DailyEventObject<U> : never : never; type EventCallback<T extends DailyEvent | DailyEvent[]> = (events: EventObjectsFor<T>[]) => void; /** * Sets up a throttled daily event listener using [on](https://docs.daily.co/reference/daily-js/instance-methods/on) method. * When this hook is unmounted the event listener is unregistered using [off](https://docs.daily.co/reference/daily-js/instance-methods/off). * * In comparison to useDailyEvent the callback passed here will be called with an array of event objects. * * You can pass an array of DailyEvents to register multiple daily events with a single callback handler. * The events returned in the callback parameter are guaranteed to be in the same order as they were emitted. * * @param ev The DailyEvent to register or an array of DailyEvent to register. * @param callback A memoized callback reference to run when throttled events are emitted. * @param throttleTimeout The minimum waiting time until the callback is called again. Default: 500 */ export declare const useThrottledDailyEvent: <T extends DailyEvent>(ev: T | T[], callback: EventCallback<EnsureArray<T>>, throttleTimeout?: number, INTERNAL_priority?: boolean) => void; export {};