Brama.EventDispatcher (Brama v1.0.0)

View Source

Handles event dispatching and subscription management for Brama.

This module is responsible for:

  • Maintaining a registry of event subscribers
  • Filtering events based on subscriber preferences
  • Dispatching events to interested subscribers

Summary

Functions

Returns a specification to start this module under a supervisor.

Dispatches an event to all matching subscribers.

Starts the event dispatcher.

Subscribes to Brama events.

Unsubscribes from Brama events.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

dispatch(event_type, connection, scope, data)

@spec dispatch(atom(), String.t(), String.t() | nil, map()) :: :ok

Dispatches an event to all matching subscribers.

This function constructs an event map and notifies all subscribers whose filters match the event.

start_link(opts \\ [])

Starts the event dispatcher.

subscribe(opts \\ [])

@spec subscribe(Keyword.t()) :: {:ok, reference()} | {:error, term()}

Subscribes to Brama events.

Options

  • :events - List of event types to subscribe to (default: all)
  • :connection - Connection identifier to filter by (default: all)
  • :scope - Connection scope to filter by (default: all)

unsubscribe(opts \\ [])

@spec unsubscribe(Keyword.t()) :: :ok | {:error, term()}

Unsubscribes from Brama events.