Skip to main content
Version: v7.0.0

useListener


Import
import { useListener } from "@hyper-fetch/react"

Parameters

useListener<ListenerType>(listener: ListenerType, options: UseListenerOptionsType)
Parameters
NameTypeDescription
listener
ListenerType
options
UseListenerOptionsType

Returns

useListener
NameTypeDescription
connected
boolean
connecting
boolean
data
unknown
extra
any
timestamp
null | number
listen
() => void
onConnected
(callback: VoidFunction) => void
onConnecting
(callback: VoidFunction) => void
onDisconnected
(callback: VoidFunction) => void
onError
<ErrorType>(callback: (event: ErrorType) => void) => void
onEvent
(callback: (response: { data: ExtractListenerResponseType<ListenerType>; extra: Record<string, any> }) => void) => void
onReconnecting
(callback: (data: { attempts: number }) => void) => void
onReconnectingFailed
(callback: (data: { attempts: number }) => void) => void
setConnected
(connected: boolean) => void
setConnecting
(connecting: boolean) => void
setData
(data: unknown) => void
setExtra
(extra: any) => void
setTimestamp
(timestamp: null | number) => void
React
On this page