useIpcRendererInvoke
リアクティブな ipcRenderer.invoke API の結果。非同期操作を同期操作のように見せます。@vueuse/electron アドオンで利用可能です。
使用方法
ts
import { useIpcRendererInvoke } from '@vueuse/electron'
// enable nodeIntegration if you don't provide ipcRenderer explicitly
// @see: https://electron.dokyumento.jp/docs/api/webview-tag#nodeintegration
// Ref result will return
const result = useIpcRendererInvoke<string>('custom-channel', 'some data')
const msg = computed(() => result.value?.msg)
js
import { useIpcRendererInvoke } from '@vueuse/electron'
// enable nodeIntegration if you don't provide ipcRenderer explicitly
// @see: https://electron.dokyumento.jp/docs/api/webview-tag#nodeintegration
// Ref result will return
const result = useIpcRendererInvoke('custom-channel', 'some data')
const msg = computed(() => result.value?.msg)
型宣言
型宣言を表示
typescript
/**
* Returns Promise<any> - Resolves with the response from the main process.
*
* Send a message to the main process via channel and expect a result ~~asynchronously~~. As composition-api, it makes asynchronous operations look like synchronous.
*
* You need to provide `ipcRenderer` to this function.
*
* @see https://electron.dokyumento.jp/docs/api/ipc-renderer#ipcrendererinvokechannel-args
* @see https://vueuse.dokyumento.jp/useIpcRendererInvoke
*/
export declare function useIpcRendererInvoke<T>(
ipcRenderer: IpcRenderer,
channel: string,
...args: any[]
): Ref<T | null>
/**
* Returns Promise<any> - Resolves with the response from the main process.
*
* Send a message to the main process via channel and expect a result ~~asynchronously~~. As composition-api, it makes asynchronous operations look like synchronous.
*
* `ipcRenderer` will be automatically gotten.
*
* @see https://electron.dokyumento.jp/docs/api/ipc-renderer#ipcrendererinvokechannel-args
* @see https://vueuse.dokyumento.jp/useIpcRendererInvoke
*/
export declare function useIpcRendererInvoke<T>(
channel: string,
...args: any[]
): Ref<T | null>
ソース
貢献者
変更履歴
v12.0.0-beta.1
2024/11/21v10.0.0-beta.5
2023/4/13cb644
- refactor!: isFunction
と isString
ユーティリティを削除