fixed subscription

This commit is contained in:
Fabian Vogelsteller 2017-01-26 10:35:40 +01:00
parent aad9ae5a12
commit d101973a8f
No known key found for this signature in database
GPG Key ID: E51EADA77F1A4124

View File

@ -171,8 +171,8 @@ Subscription.prototype.unsubscribe = function(callback) {
* Subscribes and watches for changes
*
* @method subscribe
* @param {String} the subscription
* @param {Object} the options object with address topics and fromBlock
* @param {String} subscription the subscription
* @param {Object} options the options object with address topics and fromBlock
* @return {Object}
*/
Subscription.prototype.subscribe = function() {
@ -208,7 +208,6 @@ Subscription.prototype.subscribe = function() {
}
// create subscription
if (_this.callback) {
if(typeof payload.params[1] === 'object')
delete payload.params[1].fromBlock;
@ -251,18 +250,18 @@ Subscription.prototype.subscribe = function() {
}
// call the callback, last so that unsubscribe there won't affect the emit above
if (_.isFunction(_this.callback)) {
_this.callback(err, output, _this);
}
});
} else {
} else if (_.isFunction(_this.callback)) {
_this.callback(err, null, _this);
_this.emit('error', err);
}
});
// return an object to cancel the subscription
return this;
} else
throw new Error('Subscriptions require a callback as the last parameter!');
};
module.exports = Subscription;