@hyper-fetch/react
Version:
React hooks and utils for the hyper-fetch
27 lines • 1.3 kB
TypeScript
import { EmitterInstance, EmitterCallbackErrorType, EmitType } from '@hyper-fetch/sockets';
import { UseEmitterOptionsType } from '.';
/** Send messages through a socket emitter with tracked connection state and lifecycle callbacks. */
export declare const useEmitter: <EmitterType extends EmitterInstance>(emitter: EmitterType, options?: UseEmitterOptionsType) => {
onEmit: (callback: (emitter: EmitterType) => void) => void;
onEmitError: (callback: EmitterCallbackErrorType) => void;
emit: EmitType<EmitterType>;
onConnected: (callback: VoidFunction) => void;
onDisconnected: (callback: VoidFunction) => void;
onError: <ErrorType = Event>(callback: (event: ErrorType) => void) => void;
onConnecting: (callback: VoidFunction) => void;
onReconnecting: (callback: (data: {
attempts: number;
}) => void) => void;
onReconnectingFailed: (callback: (data: {
attempts: number;
}) => void) => void;
setData: (data: unknown) => void;
setExtra: (extra: any) => void;
setConnected: (connected: boolean) => void;
setConnecting: (connecting: boolean) => void;
setTimestamp: (timestamp: number | null) => void;
clearState: () => void;
connected: boolean;
connecting: boolean;
};
//# sourceMappingURL=use-emitter.hooks.d.ts.map