def subscribe(&callback)
      raise AlreadySubscribedError.new if @thread
      @thread = Thread.new do
        redis.subscribe(channel) do |on|
          on.message do |channel, payload|
            data = JSON.parse(payload) rescue payload
            if data == 'unsubscribe'
              redis.unsubscribe
            else
              callback.call channel, data
            end
          end
        end
      end
    end
def subscribe(&callback)
      raise AlreadySubscribedError.new if @thread
      @thread = Thread.new do
        redis.subscribe(channel) do |on|
          on.message do |channel, payload|
            data = JSON.parse(payload) rescue payload
            if data == 'unsubscribe'
              redis.unsubscribe
            else
              callback.call channel, data
            end
          end
        end
      end
    end
Creates a subscription to the given channel
 @param channel [String] The channel to listen to
 @yield The code to execute on a published event
 @yieldparam channel [String] The channel the subscriber is listening to
 @yieldparam data [Object] The event published on the channel
 Sets up the Redis pub/sub subscription
 @yield The code to execute on a published event
 @raise [AlreadySubscribedError] If the subscriber is already subscribed