1
0
mirror of https://github.com/upscayl/upscayl.git synced 2025-02-19 04:04:38 +01:00
upscayl/renderer/components/hooks/use-electron.ts

18 lines
386 B
TypeScript
Raw Normal View History

2024-09-24 20:05:33 +05:30
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);
};
}, []);
};