Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useIpcRendererInvoke.md
1---2category: '@Electron'3---45# useIpcRendererInvoke67Reactive [ipcRenderer.invoke API](https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args) result. Make asynchronous operations look synchronous.89## Usage1011```ts12import { useIpcRendererInvoke } from '@vueuse/electron'13import { computed } from 'vue'1415// enable nodeIntegration if you don't provide ipcRenderer explicitly16// see: https://www.electronjs.org/docs/api/webview-tag#nodeintegration17// Ref result will return18const result = useIpcRendererInvoke<string>('custom-channel', 'some data')19const msg = computed(() => result.value?.msg)20```2122## Type Declarations2324```ts25/**26* Returns Promise<any> - Resolves with the response from the main process.27*28* Send a message to the main process via channel and expect a result ~~asynchronously~~. As composition-api, it makes asynchronous operations look like synchronous.29*30* You need to provide `ipcRenderer` to this function.31*32* @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args33* @see https://vueuse.org/useIpcRendererInvoke34*35* @__NO_SIDE_EFFECTS__36*/37export declare function useIpcRendererInvoke<T>(38ipcRenderer: IpcRenderer,39channel: string,40...args: any[]41): ShallowRef<T | null>42/**43* Returns Promise<any> - Resolves with the response from the main process.44*45* Send a message to the main process via channel and expect a result ~~asynchronously~~. As composition-api, it makes asynchronous operations look like synchronous.46*47* `ipcRenderer` will be automatically gotten.48*49* @see https://www.electronjs.org/docs/api/ipc-renderer#ipcrendererinvokechannel-args50* @see https://vueuse.org/useIpcRendererInvoke51*52* @__NO_SIDE_EFFECTS__53*/54export declare function useIpcRendererInvoke<T>(55channel: string,56...args: any[]57): ShallowRef<T | null>58```59