module WisperNext
Global events bus
@example
# In application boot/initialization # EVENTS = WisperNext::Events.new
EVENTS.subscribe(MyListener.new)
# Domain model # class MyCommand
def initialize(dependencies = {}) @events = dependencies.fetch(:events) { EVENTS } end def call(id) user = User.find(id) if user.promote! @events.broadcast('user_promoted', user: user) end end
end
@api public
Wraps a callable (typically a proc) so it conforms to the listener interface
@api private
Default synchronous broadcaster which sends event to subscriber
@api private
Constants
- VERSION
Public Class Methods
publisher()
click to toggle source
# File lib/wisper_next.rb, line 9 def self.publisher Publisher.new end
subscriber(*args)
click to toggle source
# File lib/wisper_next.rb, line 13 def self.subscriber(*args) Subscriber.new(*args) end