function useWSEvent
useWSEvent<K extends keyof WSEvents>(
kind: K,
handler: (event: WSEvents[K]) => void
): void

Calls handler with every event of kind the socket brings, as it arrives, for as long as the component is mounted. The handler applies it to what the component fetched, through state setters: it runs outside render, and always as the latest render defined it. The list sync hooks, the dump and playlist pages, the profile, the bell and the categories use it.

Type Parameters

K extends keyof WSEvents

Parameters

kind: K
handler: (event: WSEvents[K]) => void

Return Type

void

Usage

import { useWSEvent } from "src/hooks/ws/useWS.ts";