Files
roblox/components/providers/download-dialog-store.ts
2025-12-27 16:57:19 +02:00

31 lines
617 B
TypeScript

type DownloadDialogState = {
isOpen: boolean;
url: string | null;
};
let state: DownloadDialogState = { isOpen: false, url: null };
const listeners = new Set<() => void>();
function emit() {
listeners.forEach((l) => l());
}
export function subscribeDownloadDialog(listener: () => void) {
listeners.add(listener);
return () => listeners.delete(listener);
}
export function getDownloadDialogState() {
return state;
}
export function openDownloadDialog(url: string | null) {
state = { isOpen: true, url };
emit();
}
export function closeDownloadDialog() {
state = { isOpen: false, url: null };
emit();
}