mirror of
https://github.com/upscayl/upscayl.git
synced 2025-01-07 04:01:34 +01:00
18 lines
399 B
TypeScript
18 lines
399 B
TypeScript
|
import { useEffect } from "react";
|
||
|
import { ELECTRON_COMMANDS } from "@common/electron-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);
|
||
|
};
|
||
|
}, []);
|
||
|
};
|