Skip to content

Quick Script

This script allows you to verify your Ironflow connection and see events flowing in real-time. Use this as a diagnostic tool or a starting point for your own subscribers.


How to Run

  1. Start Ironflow: Run ./build/ironflow serve in one terminal.
  2. Run Subscriber: Run the code below in a second terminal.
  3. Trigger Events: Use ironflow emit in a third terminal to see events appear.

import { createSubscriptionClient } from "@ironflow/node";
async function main() {
const client = createSubscriptionClient({
serverUrl: "http://localhost:9123",
});
await client.connect();
// Subscribe to all system run events
await client.subscribe("system.run.>", {
onEvent: (e) => console.log(`[${e.topic}]`, e.data),
replay: 5,
});
// Subscribe to all user events
await client.subscribe("events:>", {
onEvent: (e) => console.log(`[${e.topic}]`, e.data),
replay: 5,
});
console.log("Listening for events...");
}
main().catch(console.error);

Looking for full apps?

For complete end-to-end applications using the Pub/Sub SDK, check the examples/ directory in the repository.