Docs/Event API
Universal Developer

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

EventTrigger
APP_READYApp boot complete
APP_STARTAll modules started
ALL_MODULES_LOADEDExtension set finished loading
WINDOW_ALL_CLOSEDEvery window closed
PLUGIN_STORAGE_UPDATEDPlugin storage mutated

Subscribe

EXAMPLE.TS
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.debug during debugging.

Technical Notes

  • Events originate in the main-process TouchEventBus and are bridged to plugins.
  • ctx.events wraps subscriptions and always returns a dispose function.
Was this helpful?