1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-02-15 18:32:33 +01:00
upscayl/renderer/components/hooks/use-electron.ts
2024-09-24 20:21:20 +05:30

18 lines
386 B
TypeScript

import { useEffect } from "react";
import ELECTRON_COMMANDS from "@common/commands";
const useElectron = ({
command,
func,
}: {
command: (typeof ELECTRON_COMMANDS)[keyof typeof ELECTRON_COMMANDS];
func: (...args: any[]) => void;
}) => {
useEffect(() => {
window.electron.on(command, func);
return () => {
window.electron.off(command, func);
};
}, []);
};