Event API
Event API
Overview
TouchEventBus broadcasts app lifecycle events so plugins can react without polling.
Introduction
Use the event bus for lifecycle coordination, status sync, and lightweight cross-module notifications.
API Reference
TouchEventBus
| Event | Trigger |
|---|---|
APP_READY | App boot complete |
APP_START | All modules started |
ALL_MODULES_LOADED | Extension set finished loading |
WINDOW_ALL_CLOSED | Every window closed |
PLUGIN_STORAGE_UPDATED | Plugin storage mutated |
Subscribe
const dispose = ctx.events.on('APP_READY', () => {
ctx.logger.info('App ready')
})
ctx.events.emit('PLUGIN_STORAGE_UPDATED', { pluginId: ctx.meta.id })
Custom namespaces
ctx.events.createNamespace('todo')keeps plugin events isolated.- Always release handlers in
onDestroy.
Best Practices
- Keep payloads small to avoid expensive broadcasts.
- Namespace plugin events to prevent collisions.
- Log critical payloads with
ctx.logger.debugduring debugging.
Technical Notes
- Events originate in the main-process
TouchEventBusand are bridged to plugins. ctx.eventswraps subscriptions and always returns a dispose function.
Was this helpful?