Skip to content

platform/electron/ipc-router

Defined in: app/src/platform/electron/ipc-router.ts:22

Connects request contracts to handlers in the browser process. Every request passes the IpcGate first; refused requests are dropped and logged, and the renderer only learns that the request failed.

new IpcRouter(gate, logger): IpcRouter

Defined in: app/src/platform/electron/ipc-router.ts:32

IpcGate

Sender, capability, schema and rate checks.

Logger

Receives refused requests and handler errors.

IpcRouter

handle<Req, Res>(contract, handler): Disposable

Defined in: app/src/platform/electron/ipc-router.ts:43

Handles a request channel.

Req

Res

RequestContract<Req, Res>

The channel’s contract.

(request, context) => Res | Promise<Res>

Produces the response; its result is checked against the contract.

Disposable

A disposable that removes the handler.

handleLater(channels, register): void

Defined in: app/src/platform/electron/ipc-router.ts:88

Handles request channels whose contracts and handlers load with the first request on any of them, so that the browser does not load them at its start. The first request waits for them; every request passes the same checks as with IpcRouter.handle.

readonly string[]

The channels; register must handle each of them.

() => Promise<void>

Loads the contracts and handlers, and handles the channels.

void

publish<T>(contract, target, payload): void

Defined in: app/src/platform/electron/ipc-router.ts:111

Sends an event to a view if it has the contract’s capability.

T

EventContract<T>

The event’s contract.

WebContents

Receiving view.

T

The event payload.

void

Defined in: app/src/platform/electron/ipc-router.ts:9

Context passed to a request handler.

readonly sender: WebContents

Defined in: app/src/platform/electron/ipc-router.ts:11

The WebContents that sent the request.