# `DDD.EventBus`
[🔗](https://github.com/blackuprise/vicander/blob/v0.1.1/lib/ddd/events/event_bus.ex#L1)

Simple in-process pub/sub event bus.

In production replace with Phoenix.PubSub, Broadway, or a message broker.

## Usage

    DDD.EventBus.subscribe(MyApp.Events.OrderPlaced, MyApp.Handlers.SendEmail)
    DDD.EventBus.publish(event)

    defmodule MyApp.Handlers.SendEmail do
      def handle(%MyApp.Events.OrderPlaced{} = event) do
        MyApp.Mailer.send_confirmation(event.customer_id)
      end
    end

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `handlers_for`

Handler modules subscribed to an event type, in subscription order.

# `init`

# `publish`

Publish a single domain event.

# `publish_all`

Publish a list of domain events.

# `start_link`

# `subscribe`

Subscribe a handler module to an event type. Subscribing twice has no extra effect.

# `unsubscribe`

Remove a handler's subscription to an event type.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
