Ziya/electron/handlers/ipc-handlers.ts
rizary 67fb3a203e
feat: implement CEX analysis cards and real-time token monitoring
- Add TokenCard and CexAnalysisCard components for displaying token data
- Implement real-time Redis event streaming for token updates
- Add environment-based configuration system for dev/prod Redis servers
- Create comprehensive hunting ground dashboard with card management
- Add individual and bulk card removal functionality
- Implement browser integration for token details viewing
- Add timestamp utilities and proper type handling for Redis events
- Create production-ready configuration with 154.38.185.112 Redis server
- Add comprehensive documentation in README.md and CONTRIBUTORS.md
- Restructure project architecture with proper Electron-Vue integration

BREAKING CHANGE: Redis configuration now uses environment-based settings
2025-06-23 09:03:39 +07:00

28 lines
725 B
TypeScript

import { ipcMain } from 'electron';
type IpcHandler<T = unknown, R = unknown> = (event: Electron.IpcMainInvokeEvent, ...args: T[]) => Promise<R> | R;
/**
* Utility function to define IPC handlers with better type safety and error handling
*/
export function defineIpcHandler<T = unknown, R = unknown>(
channel: string,
handler: IpcHandler<T, R>,
): void {
ipcMain.handle(channel, async (event, ...args) => {
try {
return await handler(event, ...args);
}
catch (error) {
console.error(`Error in IPC handler '${channel}':`, error);
throw error;
}
});
}
/**
* Remove an IPC handler
*/
export function removeIpcHandler(channel: string): void {
ipcMain.removeHandler(channel);
}