From 5b53d59cbaf2daa5720b29e2df04b4a92a28bdd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Wed, 16 Apr 2014 10:01:31 +0200 Subject: [PATCH] Add optional callback to `pollBalance` --- lib/trader.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/trader.js b/lib/trader.js index 43db0309..d7698e93 100644 --- a/lib/trader.js +++ b/lib/trader.js @@ -155,7 +155,7 @@ Trader.prototype.stopPolling = function () { clearInterval(this.rateInterval); }; -Trader.prototype.pollBalance = function () { +Trader.prototype.pollBalance = function (callback) { var self = this; self.logger.info('collecting balance'); @@ -170,9 +170,15 @@ Trader.prototype.pollBalance = function () { self.tradeExchange.balance(next); } }, function (err, balance) { + if (err) { + return callback && callback(err); + } + balance.timestamp = Date.now(); self.logger.info('Balance update:', balance); self.balance = balance; + + callback && callback(null, balance); }); };