emarsys-integration-client
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -23,2 +23,3 @@ 'use strict'; | ||
_this.deferreds = {}; | ||
_this.timeoutIds = {}; | ||
receiver.addMessageHandler('navigate:response', _this.handleResponse.bind(_this)); | ||
@@ -34,2 +35,3 @@ receiver.addMessageHandler('get_url:response', _this.handleResponse.bind(_this)); | ||
if (this.deferreds[message.data.id]) { | ||
clearTimeout(this.timeoutIds[message.data.id]); | ||
if (message.data.success) { | ||
@@ -85,7 +87,20 @@ this.deferreds[message.data.id].resolve(message); | ||
value: function sendMessage(eventName, eventPayload) { | ||
var _this2 = this; | ||
var eventId = this.getRandomId(); | ||
this.deferreds[eventId] = defer(); | ||
this.timeoutIds[eventId] = setTimeout(function () { | ||
console.error('No response received for integrationClient request within ' + _this2.getResponseTimeout() + 'ms. Make sure emarsys-integration-js is included in the top iframe.'); | ||
_this2.deferreds[eventId].reject(new Error('No response recieved within timeout')); | ||
}, this.getResponseTimeout()); | ||
this.transmitter.messageToEmarsys(eventName, Object.assign({}, eventPayload, { eventId: eventId })); | ||
return this.deferreds[eventId].promise; | ||
} | ||
}, { | ||
key: 'getResponseTimeout', | ||
value: function getResponseTimeout() { | ||
return 2000; | ||
} | ||
}], [{ | ||
@@ -92,0 +107,0 @@ key: 'create', |
@@ -12,2 +12,3 @@ { | ||
"test": "NODE_ENV=test mocha $(find . -name \"*.spec.js\" -not -path \"./node_modules/*\" -not -path \"./dist/*\") --require babel-register", | ||
"test:watch": "npm run test -- --watch", | ||
"validate-commit-msg": "validate-commit-msg", | ||
@@ -52,3 +53,3 @@ "watch": "npm run build -- --watch" | ||
"homepage": "https://github.com/emartech/emarsys-integration-client-js#readme", | ||
"version": "2.4.0" | ||
"version": "2.5.0" | ||
} |
Sorry, the diff of this file is not supported yet
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
35128
556