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 =
"1.0.1"
LISTENERS_HASH =
Concurrent::Map.new do |h, k|
  h.compute_if_absent(k) { [] }
end
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
UnregisteredEventError =
Class.new(StandardError) do
  def initialize(object_or_event_id)
    case object_or_event_id
    when String, Symbol
      super("You are trying to publish an unregistered event: `#{object_or_event_id}`")
    else
      super("You are trying to publish an unregistered event")
    end
  end
end