Skip to content

subscribe() should accept a callback #122

@gairal

Description

@gairal

Hi,

First, awesome work on this module!

I couldn't properly mock client.subscribe('channelName', (err, channels) => {...}) using the last argument as a callback
From redis-node: https://github.com/NodeRedis/node_redis/blob/27bb93ac19157bdc7b7958bef012e4b266d156ae/lib/individualCommands.js#L429-L435

From redis-mock: https://github.com/yeahoffline/redis-mock/blob/master/lib/pubsub.js#L23
The potential callback is not executed

something along the lines of this should do

for (var i = 0; i < arguments.length; i++) {
  [...]
}

if ('function' === typeof arguments[arguments.length - 1]) {
  arguments[arguments.length - 1](
    null, // no error
    // send back all the channel names
    Array.prototype.slice.call(arguments, 0, arguments.length - 1)
  );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions