Comparing version 4.0.0 to 4.1.0
@@ -137,2 +137,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
this._notificationReceivers = []; | ||
this._commandReceivers = []; | ||
this._commandResolves = {}; | ||
@@ -240,2 +241,3 @@ this.sessionPromise = new _bluebird2.default(function () {}); | ||
}; | ||
this._clientChannel.onNotification = function (notification) { | ||
@@ -246,4 +248,8 @@ return _this2._notificationReceivers.forEach(function (receiver) { | ||
}; | ||
this._clientChannel.onCommand = function (c) { | ||
return (_this2._commandResolves[c.id] || identity)(c); | ||
(_this2._commandResolves[c.id] || identity)(c); | ||
_this2._commandReceivers.forEach(function (receiver) { | ||
return receiver.predicate(c) && receiver.callback(c); | ||
}); | ||
}; | ||
@@ -410,19 +416,7 @@ | ||
if (typeof predicate !== 'function') { | ||
if (predicate === true || !predicate) { | ||
predicate = function predicate() { | ||
return true; | ||
}; | ||
} else { | ||
var value = predicate; | ||
predicate = function predicate(message) { | ||
return message.type === value; | ||
}; | ||
} | ||
} | ||
predicate = this.processPredicate(predicate); | ||
this._messageReceivers.push({ predicate: predicate, callback: callback }); | ||
return function () { | ||
return _this5._messageReceivers = _this5._messageReceivers.filter(function (r) { | ||
return r.predicate !== predicate && r.callback !== callback; | ||
}); | ||
return _this5._messageReceivers = _this5._messageReceivers.filter(_this5.filterReceiver(predicate, callback)); | ||
}; | ||
@@ -436,2 +430,22 @@ } | ||
// addCommandReceiver :: Function -> (Command -> ()) -> Function | ||
}, { | ||
key: 'addCommandReceiver', | ||
value: function addCommandReceiver(predicate, callback) { | ||
var _this6 = this; | ||
predicate = this.processPredicate(predicate); | ||
this._commandReceivers.push({ predicate: predicate, callback: callback }); | ||
return function () { | ||
return _this6._commandReceivers = _this6._commandReceivers.filter(_this6.filterReceiver(predicate, callback)); | ||
}; | ||
} | ||
}, { | ||
key: 'clearCommandReceivers', | ||
value: function clearCommandReceivers() { | ||
this._commandReceivers = []; | ||
} | ||
// addNotificationReceiver :: String -> (Notification -> ()) -> Function | ||
@@ -442,4 +456,19 @@ | ||
value: function addNotificationReceiver(predicate, callback) { | ||
var _this6 = this; | ||
var _this7 = this; | ||
predicate = this.processPredicate(predicate); | ||
this._notificationReceivers.push({ predicate: predicate, callback: callback }); | ||
return function () { | ||
return _this7._notificationReceivers = _this7._notificationReceivers.filter(_this7.filterReceiver(predicate, callback)); | ||
}; | ||
} | ||
}, { | ||
key: 'clearNotificationReceivers', | ||
value: function clearNotificationReceivers() { | ||
this._notificationReceivers = []; | ||
} | ||
}, { | ||
key: 'processPredicate', | ||
value: function processPredicate(predicate) { | ||
if (typeof predicate !== 'function') { | ||
@@ -452,18 +481,16 @@ if (predicate === true || !predicate) { | ||
var value = predicate; | ||
predicate = function predicate(notification) { | ||
return notification.event === value; | ||
predicate = function predicate(envelope) { | ||
return envelope.event === value || envelope.type === value; | ||
}; | ||
} | ||
} | ||
this._notificationReceivers.push({ predicate: predicate, callback: callback }); | ||
return function () { | ||
return _this6._notificationReceivers = _this6._notificationReceivers.filter(function (r) { | ||
return r.predicate !== predicate && r.callback !== callback; | ||
}); | ||
}; | ||
return predicate; | ||
} | ||
}, { | ||
key: 'clearNotificationReceivers', | ||
value: function clearNotificationReceivers() { | ||
this._notificationReceivers = []; | ||
key: 'filterReceiver', | ||
value: function filterReceiver(predicate, callback) { | ||
return function (r) { | ||
return r.predicate !== predicate && r.callback !== callback; | ||
}; | ||
} | ||
@@ -470,0 +497,0 @@ }, { |
{ | ||
"name": "blip-sdk", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "BLiP SDK JavaScript", | ||
@@ -50,3 +50,3 @@ "main": "dist/blip-sdk.js", | ||
"mocha": "^2.3.4", | ||
"semantic-release": "^15.4.1", | ||
"semantic-release": "^15.9.15", | ||
"webpack": "^1.12.9" | ||
@@ -63,7 +63,4 @@ }, | ||
"path": "./node_modules/cz-conventional-changelog" | ||
}, | ||
"ghooks": { | ||
"pre-commit": "npm run lint && npm run test:single && npm run test:check-coverage" | ||
} | ||
} | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
35836
633
0