Module: Dry::Events

Includes:
Core::Constants
Defined in:
lib/dry/events/bus.rb,
lib/dry/events/event.rb,
lib/dry/events/filter.rb,
lib/dry/events/version.rb,
lib/dry/events/listener.rb,
lib/dry/events/constants.rb,
lib/dry/events/publisher.rb

Defined Under Namespace

Classes: Bus, Event, Filter, Listener, Publisher

Constant Summary collapse

VERSION =
'0.2.0'.freeze
LISTENERS_HASH =
Concurrent::Map.new { |h, k| h[k] = [] }
PublisherAlreadyRegisteredError =

Exception raised when the same publisher is registered more than once

Class.new(StandardError) do
  # @api private
  def initialize(id)
    super("publisher with id #{id.inspect} already registered as: #{Publisher.registry[id]}")
  end
end
InvalidSubscriberError =
Class.new(StandardError) do
  # @api private
  def initialize(object_or_event_id)
    case object_or_event_id
    when String, Symbol
      super("you are trying to subscribe to an event: `#{object_or_event_id}` that has not been registered")
    else
      super("you try use subscriber object that will never be executed")
    end
  end
end