Module: ROM::Notifications
Overview
Notification subsystem
This is an abstract event bus that implements a simple pub/sub protocol. The Notifications module is used in the setup process to decouple different modules from each other.
Defined Under Namespace
Modules: Listener, Publisher Classes: Event, EventBus
Constant Summary collapse
- LISTENERS_HASH =
Hash.new { |h, k| h[k] = [] }
Class Method Summary collapse
-
.event_bus(id) ⇒ Notifications::EventBus
Build an event bus.
-
.subscribe(event_id, query = EMPTY_HASH) {|block| ... } ⇒ Object
extended
from Publisher
Subscribe to events.
-
.trigger(event_id, payload = EMPTY_HASH) ⇒ Object
extended
from Publisher
Trigger an event.
Instance Method Summary collapse
-
#register_event(id, info = EMPTY_HASH) ⇒ Object
Register an event.
Class Method Details
.event_bus(id) ⇒ Notifications::EventBus
Build an event bus
180 181 182 |
# File 'core/lib/rom/support/notifications.rb', line 180 def self.event_bus(id) EventBus.new(id, events: events.dup, listeners: listeners.dup) end |
.subscribe(event_id, query = EMPTY_HASH) {|block| ... } ⇒ Object Originally defined in module Publisher
Subscribe to events. If the query parameter is provided, filters events by payload.
.trigger(event_id, payload = EMPTY_HASH) ⇒ Object Originally defined in module Publisher
Trigger an event
Instance Method Details
#register_event(id, info = EMPTY_HASH) ⇒ Object
Register an event
160 161 162 |
# File 'core/lib/rom/support/notifications.rb', line 160 def register_event(id, info = EMPTY_HASH) Notifications.events[id] = Event.new(id, info) end |