Beignet API reference
    Preparing search index...
    • 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.

      Parameters

      Returns EventBusPort

      const eventBus = createInMemoryEventBus();

      eventBus.subscribe(UserRegistered, (payload) => {
      console.log(`User registered: ${payload.email}`);
      });

      await eventBus.publish(UserRegistered, { userId: "123", email: "test@example.com" });
      // With error handling
      const eventBus = createInMemoryEventBus({
      onHandlerError: (error, eventName, payload) => {
      logger.error(`Event handler failed for ${eventName}`, { error, payload });
      },
      });