Skip to main content
Version: v7.0.0

useEmitter


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

Parameters

useEmitter<EmitterType>(emitter: EmitterType, options: UseEmitterOptionsType)
Parameters
NameTypeDescription
emitter
EmitterType
options
UseEmitterOptionsType

Returns

useEmitter
NameTypeDescription
connected
boolean
connecting
boolean
emit
EmitType<EmitterType>
onConnected
(callback: VoidFunction) => void
onConnecting
(callback: VoidFunction) => void
onDisconnected
(callback: VoidFunction) => void
onEmit
(callback: (emitter: EmitterType) => void) => void
onEmitError
(callback: EmitterCallbackErrorType) => void
onError
<ErrorType>(callback: (event: ErrorType) => 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