class WisperNext::Publisher
Extension to provide objects with subscription and publishing capabilties
@example
class PromoteUser
include Wisper.publisher def call # ... broadcast(:user_promoted, user_id: user.id, ts: Time.now) end
end
class NotifyUserOfPromotion
def on_event(name, payload) puts "#{name} => #{payload.inspect}" end
end
command = PromoteUser.new command.subscribe(NotifyUserOfPromotion.new) command.call
Constants
- ListenerAlreadyRegisteredError
Exception raised when a listener is already subscribed
@api public
- NoEventHandlerError
Exception raised when a listener does not have an on_event method
@api public
Public Instance Methods
included(descendant)
click to toggle source
Calls superclass method
# File lib/wisper_next/publisher.rb, line 27 def included(descendant) super descendant.send(:include, Methods) end