MCPcopy
hub / github.com/vueuse/vueuse / UseIpcRendererReturn

Interface UseIpcRendererReturn

packages/electron/useIpcRenderer/index.ts:13–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11 * @see https://www.electronjs.org/docs/api/ipc-renderer
12 */
13export interface UseIpcRendererReturn {
14 /**
15 * Listens to channel, when a new message arrives listener would be called with listener(event, args...).
16 * [ipcRenderer.removeListener](https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener) automatically on unmounted.
17 *
18 * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereronchannel-listener
19 */
20 on: (channel: string, listener: IpcRendererListener) => IpcRenderer
21
22 /**
23 * Adds a one time listener function for the event. This listener is invoked only the next time a message is sent to channel, after which it is removed.
24 *
25 * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendereroncechannel-listener
26 */
27 once: (channel: string, listener: (event: IpcRendererEvent, ...args: any[]) => void) => IpcRenderer
28
29 /**
30 * Removes the specified listener from the listener array for the specified channel.
31 *
32 * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener
33 */
34 removeListener: (channel: string, listener: (...args: any[]) => void) => IpcRenderer
35
36 /**
37 * Removes all listeners, or those of the specified channel.
38 *
39 * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererremovealllistenerschannel
40 */
41 removeAllListeners: (channel: string) => IpcRenderer
42
43 /**
44 * Send an asynchronous message to the main process via channel, along with arguments.
45 *
46 * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendchannel-args
47 */
48 send: (channel: string, ...args: any[]) => void
49
50 /**
51 * Returns Promise<any> - Resolves with the response from the main process.
52 * Send a message to the main process via channel and expect a result ~~asynchronously~~.
53 * As composition-api, it makes asynchronous operations look like synchronous.
54 *
55 * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args
56 */
57 invoke: <T>(channel: string, ...args: any[]) => ShallowRef<T | null>
58
59 /**
60 * Returns any - The value sent back by the ipcMain handler.
61 * Send a message to the main process via channel and expect a result synchronously.
62 *
63 * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendsyncchannel-args
64 */
65 sendSync: <T>(channel: string, ...args: any[]) => ShallowRef<T | null>
66
67 /**
68 * Send a message to the main process, optionally transferring ownership of zero or more MessagePort objects.
69 *
70 * @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererpostmessagechannel-message-transfer

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected