Skip to main content
Version: 3.x.x

useEventMessages


import { useEventMessages } from "@hyper-fetch/react"

Description

Defined in react/src/hooks/use-event-messages/use-event-messages.hooks.ts:15

Preview

useEventMessages<ResponsesType>(socket, options)

Parameters

NameDetails

socket

Required

SocketInstance

options

Required

UseEventMessagesOptionsType<ResponsesType>

Returns

{
connected: boolean;
connecting: boolean;
data: unknown;
onClose: (callback: VoidFunction) => void;
onConnecting: (callback: VoidFunction) => void;
onError: (callback: (event: ErrorType) => void) => void;
onEvent: (callback: (data: ResponsesType, event: MessageEvent<ResponsesType>) => void) => void;
onOpen: (callback: VoidFunction) => void;
onReconnecting: (callback: (attempts: number) => void) => void;
onReconnectingStop: (callback: (attempts: number) => void) => void;
setConnected: (connected: boolean) => void;
setConnecting: (connecting: boolean) => void;
setData: (data: unknown) => void;
setTimestamp: (timestamp: number) => void;
timestamp: number;
}