From c95bac4cf93252eeafbae927d2171b84e9fbce88 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 15 Nov 2012 14:25:54 +0400 Subject: [PATCH 1/2] return amount of subscribers received the published message Redis returns amount of subscribers received the message, in some cases it's essential to have it so I don't see a reason to hide return value in wrapper. --- index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 31e6a85..8ee1501 100644 --- a/index.js +++ b/index.js @@ -63,11 +63,17 @@ exports.attach = function (options) { amino.publish = function () { var args = Array.prototype.slice.call(arguments) , ev = args.shift() + , cb = args.pop(); + + if(typeof cb != 'function') { + if(cb!==undefined) args.push(cb); // don't push empty values + cb = function(){}; + } try { args = {args: args}; // (dehydration only works on objects) args = hydration.dehydrate(args); - client.publish(ev, JSON.stringify(args)); + client.publish(ev, JSON.stringify(args), cb); } catch (e) { amino.emit('error', e); From 7250c8999c047d6a83dd355dce8bf8c7ba1a40e1 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Thu, 15 Nov 2012 15:07:00 +0400 Subject: [PATCH 2/2] fix for publish commit --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8ee1501..af4e63f 100644 --- a/index.js +++ b/index.js @@ -66,7 +66,8 @@ exports.attach = function (options) { , cb = args.pop(); if(typeof cb != 'function') { - if(cb!==undefined) args.push(cb); // don't push empty values + if(typeof cb!=='undefined') + args.push(cb); // don't push empty values cb = function(){}; }