platform/electron/ipc-router
Classes
Section titled “Classes”IpcRouter
Section titled “IpcRouter”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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new IpcRouter(
gate,logger):IpcRouter
Defined in: app/src/platform/electron/ipc-router.ts:32
Parameters
Section titled “Parameters”Sender, capability, schema and rate checks.
logger
Section titled “logger”Receives refused requests and handler errors.
Returns
Section titled “Returns”Methods
Section titled “Methods”handle()
Section titled “handle()”handle<
Req,Res>(contract,handler):Disposable
Defined in: app/src/platform/electron/ipc-router.ts:43
Handles a request channel.
Type Parameters
Section titled “Type Parameters”Req
Res
Parameters
Section titled “Parameters”contract
Section titled “contract”RequestContract<Req, Res>
The channel’s contract.
handler
Section titled “handler”(request, context) => Res | Promise<Res>
Produces the response; its result is checked against the contract.
Returns
Section titled “Returns”A disposable that removes the handler.
handleLater()
Section titled “handleLater()”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.
Parameters
Section titled “Parameters”channels
Section titled “channels”readonly string[]
The channels; register must handle each of them.
register
Section titled “register”() => Promise<void>
Loads the contracts and handlers, and handles the channels.
Returns
Section titled “Returns”void
publish()
Section titled “publish()”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.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”contract
Section titled “contract”The event’s contract.
target
Section titled “target”WebContents
Receiving view.
payload
Section titled “payload”T
The event payload.
Returns
Section titled “Returns”void
Interfaces
Section titled “Interfaces”IpcContext
Section titled “IpcContext”Defined in: app/src/platform/electron/ipc-router.ts:9
Context passed to a request handler.
Properties
Section titled “Properties”sender
Section titled “sender”
readonlysender:WebContents
Defined in: app/src/platform/electron/ipc-router.ts:11
The WebContents that sent the request.