Method: MessageBus::Backends::Memory#subscribe
- Defined in:
- lib/message_bus/backends/memory.rb
#subscribe(channel, last_id = nil) {|message| ... } ⇒ nil
Subscribe to messages on a particular channel. Each message since the last ID specified will be delivered by yielding to the passed block as soon as it is available. This will block until subscription is terminated.
271 272 273 274 275 276 277 278 279 |
# File 'lib/message_bus/backends/memory.rb', line 271 def subscribe(channel, last_id = nil) # trivial implementation for now, # can cut down on connections if we only have one global subscriber raise ArgumentError unless block_given? global_subscribe(last_id) do |m| yield m if m.channel == channel end end |