Skip to main content
Version: 5.x.x

useEmitter


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

Description

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

Preview

useEmitter<EmitterType>(emitter, options)

Parameters

NameDetails

emitter

Required

EmitterType

options

Required

UseEmitterOptionsType

Returns

{
connected: boolean;
connecting: boolean;
emit: ExtractEmitterHasDataType<Emitter> extends false ? (options: [object Object]) => string : (ExtractRouteParams<ExtractEmitterEndpointType<Emitter>> extends NegativeTypes ? (options?: [object Object]) => string : (ExtractEmitterHasParamsType<Emitter> extends false ? (options: [object Object]) => string : (options?: [object Object]) => string));
onClose: (callback: VoidFunction) => void;
onConnecting: (callback: VoidFunction) => void;
onError: (callback: (event: ErrorType) => void) => void;
onEvent: (callback: (emitter: EmitterType) => void) => void;
onOpen: (callback: VoidFunction) => void;
onReconnecting: (callback: (attempts: number) => void) => void;
onReconnectingStop: (callback: (attempts: number) => void) => void;
reconnect: number;
setConnected: (connected: boolean) => void;
setConnecting: (connecting: boolean) => void;
setData: (data: unknown) => void;
setTimestamp: (timestamp: number) => void;
timestamp: number;
}