bus.on(pattern, handler)for subscriptionsbus.find(pattern, ...)for history/future lookup
- event class
- string event type name
'*'wildcard (match everything)
bus.On(...) in Go, EventSpec/BaseEvent in Rust) when you want payload/result validation.
Supported pattern forms
.on(...) and .find(...) use the same pattern model
Use whichever operation you need, with the same pattern key:
- subscribe:
bus.on(UserActionEvent, handler) - find by class:
await bus.find(UserActionEvent) - find by string:
await bus.find('UserActionEvent') - wildcard subscribe/find:
bus.on('*', ...),await bus.find('*', ...)
Examples
- Python
- TypeScript
- Rust
- Go
Why event classes are preferred for typing
Event classes preserve the most useful static typing:- handler input shape is specific (payload fields are known)
- event result typing stays aligned with
event_result_type/ generic result type .find(EventClass)returns the specific event type
'*' are intentionally looser:
- Python: treat as
BaseEvent[Any] - TypeScript: typed as base
BaseEvent/unknown-oriented handler return checks - Rust: typed handlers use
bus.on(MyEvent, ...); raw string/wildcard registration is reserved for low-level forwarding internals. - Go: typed handlers use
bus.On(...); string/wildcard handlers usebus.OnEventName(...)and receive*BaseEvent