🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
'use client';
import { useEffect, useLayoutEffect, useRef } from 'react';
import type { MainBroadcastEventKey, MainBroadcastParams } from './events';
interface ElectronAPI {
ipcRenderer: {
on: (event: MainBroadcastEventKey, listener: (e: any, data: any) => void) => () => void;
};
}
declare global {
interface Window {
electron: ElectronAPI;
}
}
export const useWatchBroadcast = <T extends MainBroadcastEventKey>(
event: T,
handler: (data: MainBroadcastParams<T>) => void,
) => {
const handlerRef = useRef<typeof handler>(handler);
useLayoutEffect(() => {
handlerRef.current = handler;
}, [handler]);
useEffect(() => {
if (!window.electron) return;
const listener = (_e: any, data: MainBroadcastParams<T>) => {
handlerRef.current(data);
};
return window.electron.ipcRenderer.on(event, listener);
}, [event]);
};