Defining events
You define events in a TypeScript file as a type with a name and payload for each event. This file needs to be registered in your config viadefinePlugin({ events: "./src/main/events.ts" }) so the framework can keep everything type-safe.
src/main/events.ts
Emitting events
From a service, emit events throughthis.ctx.rpc.emit:
Listening to events
From React, use theuseEvents hook to subscribe:
Events vs RPC vs database
- Events are for transient updates that don’t need to be persisted, like streaming terminal output or push notifications.
- RPC is for getting the main process to run code the renderer process can’t, like reading a file or calling a system API.
- Database is for state that should persist and drive your UI.

