const eventBus = createMemoryEventBus();
const subscription = eventBus.subscribe(UserRegistered, (payload) => {
console.log(`User registered: ${payload.email}`);
});
await subscription.ready;
await eventBus.publish(UserRegistered, { userId: "123", email: "test@example.com" });
await subscription.unsubscribe();
Create an in-memory event bus implementation.
This is suitable for single-process applications or testing. For distributed systems, you would implement EventBusPort with a message broker like RabbitMQ, Kafka, or Redis Pub/Sub.