/** * @file Use Realtime Stream Hook * @description Hook to subscribe to real-time updates for a specific channel. * * This hook provides WebSocket/SSE real-time communication, distinct from * the streaming/ module hooks which handle React 18 SSR HTML streaming. */ /** * Realtime stream subscription options */ export interface UseRealtimeStreamOptions { enabled?: boolean; onMessage?: (data: T) => void; onError?: (error: Error) => void; transform?: (data: unknown) => T; } /** * Realtime stream subscription result */ export interface UseRealtimeStreamResult { isConnected: boolean; lastMessage: T | null; messages: T[]; send: (data: unknown) => void; clear: () => void; } /** * Hook to subscribe to a realtime stream channel * * @example * ```tsx * function ChatComponent() { * const { messages, send, isConnected } = useRealtimeStream('chat'); * * return ( *
* {messages.map(msg =>
{msg.text}
)} * *
* ); * } * ``` */ export declare function useRealtimeStream(channel: string, options?: UseRealtimeStreamOptions): UseRealtimeStreamResult; /** * Hook to subscribe to multiple channels * * NOTE: This is a simplified version. For production use, consider * using a single subscription with channel filtering instead. * * @param channels - Array of channel names to subscribe to * @param options - Subscription options * @returns Channel count and options (placeholder for multi-channel support) * * @example * ```tsx * // Use with caution - prefer single subscription with filtering * const result = useMultiRealtimeStream(['chat', 'notifications']); * ``` */ export declare function useMultiRealtimeStream(channels: string[], options?: UseRealtimeStreamOptions): { channelCount: number; options: UseRealtimeStreamOptions; }; /** * Hook to get realtime connection state */ export declare function useRealtimeConnection(): { connectionState: string; isConnected: boolean; connect: () => void; disconnect: () => void; }; /** * Hook for buffered realtime stream updates (debounced) */ export declare function useBufferedRealtimeStream(channel: string, bufferMs?: number, options?: UseRealtimeStreamOptions): UseRealtimeStreamResult; /** * Hook to track realtime stream presence (who's online) * * @param channel - The channel to track presence for * @returns Object containing list of users and count * * @example * ```tsx * function OnlineUsers() { * const { users, count } = useRealtimePresence('chat-room'); * return
{count} users online
; * } * ``` */ export declare function useRealtimePresence(channel: string): { users: string[]; count: number; };