Parameter decorators
You can inject Electron-specific context directly into your controller methods without parsing the raw event object manually.
| Decorator | Injects | Type |
|---|---|---|
@Channel() | The IPC channel name for this handler (e.g. "users.get_profile") | string |
@CorrelationId() | The unique ID for the current request context. If you have correlation disabled, this will always return undefined | string |
@Origin() | The sender frame | WebFrameMain |
@ProcessId() | The ID of the renderer process | number |
@RawEvent() | The native Electron event object | IpcMainEvent | IpcMainInvokeEvent |
@Sender() | The WebContents that sent the message | WebContents |
@Window() | Nullable. The BrowserWindow that sent the message | BrowserWindow |
Example:
import type { WebContents } from "electron/main";
@IpcHandle()
getUserProfile(
@Sender() sender: WebContents,
userId: string
) {
console.log(`Request from window: ${sender.id}`);
return this.userService.findById(userId);
}
note
When using the generated types in the frontend, these injected parameters are automatically removed from the function signature. You simply call getUserProfile('123').