コンテンツにスキップ

useIpcRendererInvoke

カテゴリ
エクスポートサイズ
218 バイト
パッケージ
@vueuse/electron
最終変更日
先週

リアクティブな 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>

ソース

ソースドキュメント

貢献者

Anthony Fu
Curt Grimes
ArcherGu

変更履歴

v12.0.0-beta.1 2024/11/21
0a9ed - feat!: Vue 2 のサポートを削除、バンドルを最適化、クリーンアップ (#4349)
v10.0.0-beta.5 2023/4/13
cb644 - refactor!: isFunctionisString ユーティリティを削除

MITライセンスでリリースされています。