mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 19:48:13 +00:00
fixed subscription
This commit is contained in:
parent
aad9ae5a12
commit
d101973a8f
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user