コンテンツにスキップ

useIpcRendererOn

カテゴリ
エクスポートサイズ
242 バイト
パッケージ
@vueuse/electron
最終更新日
2ヶ月前

ipcRenderer.on を簡単に使用し、アンマウント時に ipcRenderer.removeListener を自動的に実行します。 @vueuse/electron アドオンで利用可能です。

使用方法

ts
import { useIpcRendererOn } from '@vueuse/electron'

// enable nodeIntegration if you don't provide ipcRenderer explicitly
// @see: https://electron.dokyumento.jp/docs/api/webview-tag#nodeintegration
// remove listener automatically on unmounted
useIpcRendererOn('custom-event', (event, ...args) => {
  console.log(args)
})

型宣言

型宣言を表示
typescript
/**
 * Listens to channel, when a new message arrives listener would be called with listener(event, args...).
 * [ipcRenderer.removeListener](https://electron.dokyumento.jp/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener) automatically on unmounted.
 *
 * You need to provide `ipcRenderer` to this function.
 *
 * @see https://electron.dokyumento.jp/docs/api/ipc-renderer#ipcrendereronchannel-listener
 * @see https://vueuse.dokyumento.jp/useIpcRendererOn
 */
export declare function useIpcRendererOn(
  ipcRenderer: IpcRenderer,
  channel: string,
  listener: IpcRendererListener,
): IpcRenderer
/**
 * Listens to channel, when a new message arrives listener would be called with listener(event, args...).
 * [ipcRenderer.removeListener](https://electron.dokyumento.jp/docs/api/ipc-renderer#ipcrendererremovelistenerchannel-listener) automatically on unmounted.
 *
 * `ipcRenderer` will be automatically gotten.
 *
 * @see https://electron.dokyumento.jp/docs/api/ipc-renderer#ipcrendereronchannel-listener
 * @see https://vueuse.dokyumento.jp/useIpcRendererOn
 */
export declare function useIpcRendererOn(
  channel: string,
  listener: IpcRendererListener,
): IpcRenderer

ソース

ソースドキュメント

コントリビューター

Anthony Fu
Anthony Fu
ArcherGu

変更履歴

v10.0.0-beta.5 2023年4月13日
cb644 - リファクタリング: isFunctionisString ユーティリティを削除

MITライセンスに基づいてリリースされています。