Skip to main content

Method decorators

These decorators register methods to listen for IPC events. Types are generated for these methods and exposed to the renderer.

@IpcHandle(name?: string)

Registers a bidirectional handler (Request/Response) using ipcMain.handle.

In the example below, the method will be registered as window.ipc.settings.methodName.

@IpcController()
class SettingsController {
@IpcHandle()
methodName() {}
}

If name is provided, it defines the API schema in the same way as the controller decorator.

The below example would resolve to window.ipc.settings.get.

@IpcController()
class SettingsController {
@IpcHandle("get")
methodName() {}
}

@IpcOn(name?: string)

Registers a one-way listener using ipcMain.on.

  • Usage: For fire-and-forget events where the renderer doesn't wait for a result.
  • Naming: Same rules as @IpcHandle.
  • The renderer does not receive a return value
  • The generated renderer method returns void
  • Internally uses ipcRenderer.send

@IpcHandleOnce & @IpcOnce

Same as above, but the listener is removed after the first trigger.