mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-03 02:11:07 +05:30
feat(renderer): useMenuAction hook (native menu IPC -> command store)
- bridge between main-process menu events and the command dispatcher - optional transform: convert raw IPC payload to command args - extends ipc.ts with ipc.menu.on() helper - TDD: 5 unit tests covering subscription, payload transform, no-op, unmount
This commit is contained in:
@@ -95,4 +95,16 @@ export const ipc = {
|
||||
showItemInFolder: (path: string): Promise<IpcResult<void | ChannelMissing>> =>
|
||||
safeCall('app', 'showItemInFolder', path),
|
||||
},
|
||||
menu: {
|
||||
/**
|
||||
* Subscribe to a native-menu IPC channel. The callback receives the
|
||||
* raw payload(s) from the main process. Returns an unsubscribe fn.
|
||||
*/
|
||||
on: (channel: string, callback: (...args: unknown[]) => void): (() => void) => {
|
||||
if (typeof window === 'undefined' || !window.electronAPI?.on) {
|
||||
return () => {};
|
||||
}
|
||||
return window.electronAPI.on(channel, callback as (...a: any[]) => void);
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user