
import React, { ReactNode } from "react";

//#region src/utils/react/useEventBus.d.ts
type EventBusListener<T = any> = (data: T) => void;
interface EventBusContextValue {
  emit: <T = any>(event: string, data?: T) => void;
  emitSync: <T = any>(event: string, data?: T) => void;
  on: <T = any>(event: string, listener: EventBusListener<T>) => () => void;
  off: <T = any>(event: string, listener: EventBusListener<T>) => void;
}
interface EventBusProviderProps {
  children: ReactNode;
}
/**
 * EventBusProvider provides a global event system for the application.
 *
 * @example
 * ```tsx
 * function App() {
 *   return (
 *     <EventBusProvider>
 *       <YourComponents />
 *     </EventBusProvider>
 *   );
 * }
 * ```
 */
declare function EventBusProvider({
  children
}: EventBusProviderProps): React.FunctionComponentElement<React.ProviderProps<EventBusContextValue | null>>;
/**
 * Hook to access the event bus functionality.
 * Must be used within an EventBusProvider.
 *
 * @example
 * ```tsx
 * function Component() {
 *   const { emit, emitSync, on } = useEventBus();
 *
 *   const handleClick = () => {
 *     emit('user-action', { type: 'click', target: 'button' });
 *   };
 *
 *   const handleSyncAction = () => {
 *     emitSync('sync-action', { immediate: true });
 *   };
 *
 *   useEffect(() => {
 *     const unsubscribe = on('data-updated', (data) => {
 *       console.log('Data updated:', data);
 *     });
 *
 *     return unsubscribe;
 *   }, [on]);
 *
 *   return (
 *     <div>
 *       <button onClick={handleClick}>Async Event</button>
 *       <button onClick={handleSyncAction}>Sync Event</button>
 *     </div>
 *   );
 * }
 * ```
 */
declare function useEventBus(): EventBusContextValue;
/**
 * Convenience hook for subscribing to events with automatic cleanup.
 * The listener will be automatically unsubscribed when the component unmounts
 * or when the dependencies change.
 *
 * @param event - The event name to listen for
 * @param listener - The callback function to execute when the event is emitted
 * @param deps - Dependency array for the effect (similar to useEffect)
 *
 * @example
 * ```tsx
 * function NotificationComponent() {
 *   const [message, setMessage] = useState('');
 *
 *   useEventListener('notification', (data) => {
 *     setMessage(data.message);
 *   }, []);
 *
 *   return <div>{message}</div>;
 * }
 * ```
 */
declare function useEventListener<T = any>(event: string, listener: EventBusListener<T>, deps?: React.DependencyList): void;
//#endregion
export { EventBusContextValue, EventBusListener, EventBusProvider, useEventBus, useEventListener };
//# sourceMappingURL=useEventBus.d.ts.map