web3-core-subscriptions
Advanced tools
Comparing version 1.0.0-beta.52 to 1.0.0-beta.53
@@ -19,4 +19,8 @@ 'use strict'; | ||
_inherits(AbstractSubscription, _EventEmitter); | ||
function AbstractSubscription(type, method, options, utils, formatters, moduleInstance) { | ||
function AbstractSubscription(type, method) { | ||
var _this; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var utils = arguments.length > 3 ? arguments[3] : undefined; | ||
var formatters = arguments.length > 4 ? arguments[4] : undefined; | ||
var moduleInstance = arguments.length > 5 ? arguments[5] : undefined; | ||
_classCallCheck(this, AbstractSubscription); | ||
@@ -26,3 +30,3 @@ _this = _possibleConstructorReturn(this, _getPrototypeOf(AbstractSubscription).call(this)); | ||
_this.method = method; | ||
_this.options = options || null; | ||
_this.options = options; | ||
_this.utils = utils; | ||
@@ -53,14 +57,26 @@ _this.formatters = formatters; | ||
_this2.id = subscriptionId; | ||
_this2.moduleInstance.currentProvider.once('error', function (error) { | ||
_this2.moduleInstance.currentProvider.removeAllListeners(_this2.id); | ||
if (isFunction(callback)) { | ||
callback(error, false); | ||
return; | ||
} | ||
_this2.emit('error', error); | ||
_this2.removeAllListeners(); | ||
}); | ||
_this2.moduleInstance.currentProvider.on(_this2.id, function (response) { | ||
var formattedOutput = _this2.onNewSubscriptionItem(response.result); | ||
_this2.emit('data', formattedOutput); | ||
if (isFunction(callback)) { | ||
callback(false, formattedOutput); | ||
return; | ||
} | ||
_this2.emit('data', formattedOutput); | ||
}); | ||
}).catch(function (error) { | ||
_this2.emit('error', error); | ||
if (isFunction(callback)) { | ||
callback(error, null); | ||
return; | ||
} | ||
_this2.emit('error', error); | ||
_this2.removeAllListeners(); | ||
}); | ||
@@ -67,0 +83,0 @@ return this; |
@@ -5,7 +5,7 @@ import isFunction from 'lodash/isFunction'; | ||
class AbstractSubscription extends EventEmitter { | ||
constructor(type, method, options, utils, formatters, moduleInstance) { | ||
constructor(type, method, options = null, utils, formatters, moduleInstance) { | ||
super(); | ||
this.type = type; | ||
this.method = method; | ||
this.options = options || null; | ||
this.options = options; | ||
this.utils = utils; | ||
@@ -28,14 +28,26 @@ this.formatters = formatters; | ||
this.id = subscriptionId; | ||
this.moduleInstance.currentProvider.once('error', error => { | ||
this.moduleInstance.currentProvider.removeAllListeners(this.id); | ||
if (isFunction(callback)) { | ||
callback(error, false); | ||
return; | ||
} | ||
this.emit('error', error); | ||
this.removeAllListeners(); | ||
}); | ||
this.moduleInstance.currentProvider.on(this.id, response => { | ||
const formattedOutput = this.onNewSubscriptionItem(response.result); | ||
this.emit('data', formattedOutput); | ||
if (isFunction(callback)) { | ||
callback(false, formattedOutput); | ||
return; | ||
} | ||
this.emit('data', formattedOutput); | ||
}); | ||
}).catch(error => { | ||
this.emit('error', error); | ||
if (isFunction(callback)) { | ||
callback(error, null); | ||
return; | ||
} | ||
this.emit('error', error); | ||
this.removeAllListeners(); | ||
}); | ||
@@ -42,0 +54,0 @@ return this; |
@@ -19,4 +19,8 @@ (function (global, factory) { | ||
_inherits(AbstractSubscription, _EventEmitter); | ||
function AbstractSubscription(type, method, options, utils, formatters, moduleInstance) { | ||
function AbstractSubscription(type, method) { | ||
var _this; | ||
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; | ||
var utils = arguments.length > 3 ? arguments[3] : undefined; | ||
var formatters = arguments.length > 4 ? arguments[4] : undefined; | ||
var moduleInstance = arguments.length > 5 ? arguments[5] : undefined; | ||
_classCallCheck(this, AbstractSubscription); | ||
@@ -26,3 +30,3 @@ _this = _possibleConstructorReturn(this, _getPrototypeOf(AbstractSubscription).call(this)); | ||
_this.method = method; | ||
_this.options = options || null; | ||
_this.options = options; | ||
_this.utils = utils; | ||
@@ -53,14 +57,26 @@ _this.formatters = formatters; | ||
_this2.id = subscriptionId; | ||
_this2.moduleInstance.currentProvider.once('error', function (error) { | ||
_this2.moduleInstance.currentProvider.removeAllListeners(_this2.id); | ||
if (isFunction(callback)) { | ||
callback(error, false); | ||
return; | ||
} | ||
_this2.emit('error', error); | ||
_this2.removeAllListeners(); | ||
}); | ||
_this2.moduleInstance.currentProvider.on(_this2.id, function (response) { | ||
var formattedOutput = _this2.onNewSubscriptionItem(response.result); | ||
_this2.emit('data', formattedOutput); | ||
if (isFunction(callback)) { | ||
callback(false, formattedOutput); | ||
return; | ||
} | ||
_this2.emit('data', formattedOutput); | ||
}); | ||
}).catch(function (error) { | ||
_this2.emit('error', error); | ||
if (isFunction(callback)) { | ||
callback(error, null); | ||
return; | ||
} | ||
_this2.emit('error', error); | ||
_this2.removeAllListeners(); | ||
}); | ||
@@ -67,0 +83,0 @@ return this; |
{ | ||
"name": "web3-core-subscriptions", | ||
"namespace": "ethereum", | ||
"version": "1.0.0-beta.52", | ||
"version": "1.0.0-beta.53", | ||
"description": "Manages web3 subscriptions. This is an internal package.", | ||
@@ -25,4 +25,4 @@ "repository": "https://github.com/ethereum/web3.js/tree/1.0/packages/web3-core-subscriptions", | ||
"dtslint": "0.4.2", | ||
"web3-core-helpers": "1.0.0-beta.52", | ||
"web3-utils": "1.0.0-beta.52" | ||
"web3-core-helpers": "1.0.0-beta.53", | ||
"web3-utils": "1.0.0-beta.53" | ||
}, | ||
@@ -32,3 +32,3 @@ "files": [ | ||
], | ||
"gitHead": "1c89f503c90180598910d29892f6ebf92455cfe1" | ||
"gitHead": "d955a98a5fc8819ff866254ff7141a10b503b5cd" | ||
} |
# web3-core-subscriptions | ||
This is a sub package of [web3.js][repo]. | ||
The subscriptions package is used within some [web3.js][repo] packages. | ||
This is a sub module of [web3.js][repo]. | ||
The subscriptions module is used within some [web3.js][repo] modules. | ||
@@ -6,0 +6,0 @@ If you would like to know all supported subscriptions please have a look in the ```src/subscriptions``` folder. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27819
580