Skip to main content
Version: 2.x.x

useEmitter


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

Description

Defined in hooks/use-emitter/use-emitter.hooks.ts:9

Preview

useEmitter<EmitterType>(emitter, __namedParameters)

Parameters

NameDetails

emitter

Required

EmitterType

__namedParameters

Required

UseEmitterOptionsType

Returns

{
connected: boolean;
connecting: boolean;
emit: any;
onClose: (callback: VoidFunction) => void;
onConnecting: (callback: VoidFunction) => void;
onEmit: (callback: (emitter: EmitterType) => void) => void;
onError: (callback: (event: ErrorType) => void) => void;
onOpen: (callback: VoidFunction) => void;
onReconnecting: (callback: (attempts: number) => void) => void;
onReconnectingStop: (callback: (attempts: number) => void) => void;
reconnect: any;
setConnected: (connected: boolean) => void;
setConnecting: (connecting: boolean) => void;
setData: (data: unknown) => void;
setTimestamp: (timestamp: number) => void;
timestamp: number;
}