@hyper-fetch/react
Version:
React hooks and utils for the hyper-fetch
24 lines • 1.21 kB
TypeScript
import { SocketInstance, ExtractSocketExtraType } from '@hyper-fetch/sockets';
import { UseSocketStateType, UseSocketStateProps } from '..';
export declare const useSocketState: <DataType, Socket extends SocketInstance>(socket: Socket, { dependencyTracking }: UseSocketStateProps) => readonly [UseSocketStateType<Socket, DataType>, {
setData: (data: DataType | null) => void;
setExtra: (extra: ExtractSocketExtraType<Socket> | null) => void;
setConnected: (connected: boolean) => void;
setConnecting: (connecting: boolean) => void;
setTimestamp: (timestamp: number | null) => void;
clearState: () => void;
}, {
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;
}, {
readonly setRenderKey: (renderKey: keyof UseSocketStateType<Socket, DataType>) => void;
}];
//# sourceMappingURL=use-socket-state.hooks.d.ts.map