# Context.events
URL: https://lsd.tools/docs/api-context-events
Updated: 2026-07-17

## Example

```python
@tool.command("demo/watch")
def watch(ctx: Context):
    ctx.events.on("engine/run/finished", on_done)
```

## Notes

Subscribe with `on(pattern, handler)` or emit topics — use the topic enums (`Events`,
`ViewerEvents`, …), not raw strings. Handlers are `async`. A lazily populated slot — `None` when no
bus is available.

## See also

**API:** [emit](/docs/api-context-emit) · [engine](/docs/api-context-engine) · [Context](/docs/api-context)

**Guides:** [Commands & actions](/docs/tools-commands-actions)
