Files
pinkudex/components/video/videoStatusEvents.ts
2026-05-26 22:46:00 +02:00

17 lines
643 B
TypeScript

// Pure event-bus module separate from VideoIndexProvider.tsx so the
// provider file only exports a Component + a `use*` hook — that's the
// shape Next.js Fast Refresh requires to swap a Provider in place
// instead of forcing a full page reload.
const REFRESH_EVENT = "pinkudex:video-status-refresh";
export function dispatchVideoStatusRefresh() {
if (typeof window === "undefined") return;
window.dispatchEvent(new CustomEvent(REFRESH_EVENT));
}
export function subscribeVideoStatusRefresh(cb: () => void): () => void {
window.addEventListener(REFRESH_EVENT, cb);
return () => window.removeEventListener(REFRESH_EVENT, cb);
}