use-global-socket.ts 338 B

1234567891011
  1. import type { Socket } from 'socket.io-client';
  2. import type { SWRResponse } from 'swr';
  3. import { useSWRStatic } from './use-swr-static';
  4. export const GLOBAL_SOCKET_NS = '/';
  5. export const GLOBAL_SOCKET_KEY = 'globalSocket';
  6. export const useGlobalSocket = (): SWRResponse<Socket, Error> => {
  7. return useSWRStatic(GLOBAL_SOCKET_KEY);
  8. };