@robinpath/event
v0.3.0
Published
Pub/sub event emitter for RobinPath automation workflows
Readme
@robinpath/event
Pub/sub event system with named buses, listener management, history, and async waitFor
Why use this module?
The event module lets you:
- Create a named event bus with an optional max listener limit
- Subscribe a listener to an event on a named bus
- Subscribe a one-time listener that automatically removes itself after firing
- Remove a listener, all listeners for an event, or all listeners on the bus
- Emit an event with optional data, notifying all subscribed listeners
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
robinpath add @robinpath/eventQuick Start
No credentials needed — start using it right away:
event.on "workflow" "task.completed" $handlerAvailable Functions
| Function | Description |
|----------|-------------|
| event.create | Create a named event bus with an optional max listener limit |
| event.on | Subscribe a listener to an event on a named bus |
| event.once | Subscribe a one-time listener that automatically removes itself after firing |
| event.off | Remove a listener, all listeners for an event, or all listeners on the bus |
| event.emit | Emit an event with optional data, notifying all subscribed listeners |
| event.listenerCount | Get the number of listeners for a specific event or all events on a bus |
| event.eventNames | List all event names that have listeners on a bus |
| event.removeAll | Remove all listeners from all events on a bus |
| event.history | Get the emission history for a bus, optionally filtered by event name |
| event.waitFor | Wait for a specific event to be emitted, with a timeout |
| event.destroy | Destroy a named event bus and free all resources |
Examples
Subscribe a listener to an event on a named bus
event.on "workflow" "task.completed" $handlerSubscribe a one-time listener that automatically removes itself after firing
event.once "workflow" "done" $handlerRemove a listener, all listeners for an event, or all listeners on the bus
event.off "workflow" "task.completed"Integration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/event";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
event.on "workflow" "task.completed" $handler
`);Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/json— JSON module for complementary functionality
License
MIT
