Skip to main content

Decorators Reference

Class decorator​

@IpcController(namespace?: string)​

  • Marks a class as an IPC controller
  • Optional namespace defines renderer API root (for example window.ipc.users)
  • If omitted, namespace is derived from class name (UserController -> user)

Method decorators​

@IpcHandle(name?: string)​

@IpcOn(name?: string)​

  • Fire-and-forget listener (ipcMain.on)
  • Renderer call shape returns void

@IpcHandleOnce(name?: string) and @IpcOnce(name?: string)​

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

Method naming/collision rules​

  • If name is omitted, method name is used
  • Duplicate handler names inside a controller are rejected

Parameter decorators​

@Sender()​

@Window()​

  • Injects BrowserWindow.fromWebContents(event.sender)
  • Nullable: null if no matching window exists (e.g. sender is a webview or frame without a window)

@ProcessId()​

  • Injects sender process ID (number)

@RawEvent()​

@Channel()​

  • Injects the IPC channel name for the current handler (e.g. "users.get_profile").

@Origin()​

@CorrelationId()​

  • Injects current correlation ID (string | undefined)

Custom parameter decorators​

createParamDecorator<T>(resolver): (data?: T) => ParameterDecorator​

Create project-specific injection decorators from event context.