Function: ipcEventOfContext()
ipcEventOfContext<
Event>(context):Event|undefined
Get the IPC event of a service action's request, when electronIPCServiceEntrypoint serves it (to reach the invoking renderer or frame).
Type Parameters
Event
Event extends IPCInvokeEvent = IPCInvokeEvent
Parameters
context
The service action's context (this.context in a controller).
Returns
Event | undefined
The IPC event (Electron's IpcMainInvokeEvent, typed as Event), or undefined when another adapter serves the request.
Example
typescript
import {Controller, ServiceContext} from 'lakutata/com/entrypoint'
import {ipcEventOfContext} from 'lakutata/adapter/electron'
import {ServiceAction} from 'lakutata/decorator/ctrl'
import type {IpcMainInvokeEvent} from 'electron'
class WindowController extends Controller {
//ipcRenderer.invoke('lakutata:service', {cmd: 'window.url'})
@ServiceAction({cmd: 'window.url'})
public async url(): Promise<string | undefined> {
return ipcEventOfContext<IpcMainInvokeEvent>(this.context as ServiceContext)?.sender.getURL()
}
}