Method: MessageBus::Implementation#subscribe

Defined in:
lib/message_bus.rb

#subscribe(channel = nil, last_id = -1,) {|message| ... } ⇒ Proc

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 not block, but instead the callbacks will be executed asynchronously in a dedicated subscriber thread.

Parameters:

  • (defaults to: nil)

    the name of the channel to which we should subscribe

  • (defaults to: -1,)

    the channel-specific ID of the last message that the caller received on the specified channel

Yields:

  • (message)

    a message-handler block

Yield Parameters:

Returns:

  • the callback block that will be executed



426
427
428
# File 'lib/message_bus.rb', line 426

def subscribe(channel = nil, last_id = -1, &blk)
  subscribe_impl(channel, nil, last_id, &blk)
end