mirror of
https://github.com/upscayl/upscayl.git
synced 2025-02-15 18:32:33 +01:00
18 lines
386 B
TypeScript
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);
|
|
};
|
|
}, []);
|
|
};
|