diff --git a/bower.json b/bower.json
index 4d01220..8609072 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "aurelia-event-aggregator",
- "version": "1.0.0",
+ "version": "1.0.1",
"description": "A lightweight pub/sub messaging system for app-wide or per-object loosely coupled events.",
"keywords": [
"aurelia",
diff --git a/dist/amd/aurelia-event-aggregator.js b/dist/amd/aurelia-event-aggregator.js
index f8806d1..9404684 100644
--- a/dist/amd/aurelia-event-aggregator.js
+++ b/dist/amd/aurelia-event-aggregator.js
@@ -48,6 +48,22 @@ define(['exports', 'aurelia-logging'], function (exports, _aureliaLogging) {
return Handler;
}();
+ function invokeCallback(callback, data, event) {
+ try {
+ callback(data, event);
+ } catch (e) {
+ logger.error(e);
+ }
+ }
+
+ function invokeHandler(handler, data) {
+ try {
+ handler.handle(data);
+ } catch (e) {
+ logger.error(e);
+ }
+ }
+
var EventAggregator = exports.EventAggregator = function () {
function EventAggregator() {
@@ -70,24 +86,16 @@ define(['exports', 'aurelia-logging'], function (exports, _aureliaLogging) {
subscribers = subscribers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i](data, event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeCallback(subscribers[i], data, event);
}
}
} else {
subscribers = this.messageHandlers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i].handle(event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeHandler(subscribers[i], event);
}
}
};
diff --git a/dist/aurelia-event-aggregator.js b/dist/aurelia-event-aggregator.js
index 63b057a..4d7d72e 100644
--- a/dist/aurelia-event-aggregator.js
+++ b/dist/aurelia-event-aggregator.js
@@ -15,6 +15,22 @@ class Handler {
}
}
+function invokeCallback(callback, data, event) {
+ try {
+ callback(data, event);
+ } catch (e) {
+ logger.error(e);
+ }
+}
+
+function invokeHandler(handler, data) {
+ try {
+ handler.handle(data);
+ } catch (e) {
+ logger.error(e);
+ }
+}
+
/**
* Represents a disposable subsciption to an EventAggregator event.
*/
@@ -56,24 +72,16 @@ export class EventAggregator {
subscribers = subscribers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i](data, event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeCallback(subscribers[i], data, event);
}
}
} else {
subscribers = this.messageHandlers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i].handle(event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeHandler(subscribers[i], event);
}
}
}
diff --git a/dist/commonjs/aurelia-event-aggregator.js b/dist/commonjs/aurelia-event-aggregator.js
index dda083e..f5e9002 100644
--- a/dist/commonjs/aurelia-event-aggregator.js
+++ b/dist/commonjs/aurelia-event-aggregator.js
@@ -34,6 +34,22 @@ var Handler = function () {
return Handler;
}();
+function invokeCallback(callback, data, event) {
+ try {
+ callback(data, event);
+ } catch (e) {
+ logger.error(e);
+ }
+}
+
+function invokeHandler(handler, data) {
+ try {
+ handler.handle(data);
+ } catch (e) {
+ logger.error(e);
+ }
+}
+
var EventAggregator = exports.EventAggregator = function () {
function EventAggregator() {
@@ -56,24 +72,16 @@ var EventAggregator = exports.EventAggregator = function () {
subscribers = subscribers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i](data, event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeCallback(subscribers[i], data, event);
}
}
} else {
subscribers = this.messageHandlers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i].handle(event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeHandler(subscribers[i], event);
}
}
};
diff --git a/dist/es2015/aurelia-event-aggregator.js b/dist/es2015/aurelia-event-aggregator.js
index 0e6874d..c944775 100644
--- a/dist/es2015/aurelia-event-aggregator.js
+++ b/dist/es2015/aurelia-event-aggregator.js
@@ -15,6 +15,23 @@ let Handler = class Handler {
}
};
+
+function invokeCallback(callback, data, event) {
+ try {
+ callback(data, event);
+ } catch (e) {
+ logger.error(e);
+ }
+}
+
+function invokeHandler(handler, data) {
+ try {
+ handler.handle(data);
+ } catch (e) {
+ logger.error(e);
+ }
+}
+
export let EventAggregator = class EventAggregator {
constructor() {
this.eventLookup = {};
@@ -35,24 +52,16 @@ export let EventAggregator = class EventAggregator {
subscribers = subscribers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i](data, event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeCallback(subscribers[i], data, event);
}
}
} else {
subscribers = this.messageHandlers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i].handle(event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeHandler(subscribers[i], event);
}
}
}
diff --git a/dist/native-modules/aurelia-event-aggregator.js b/dist/native-modules/aurelia-event-aggregator.js
index a6ba0e2..f68d225 100644
--- a/dist/native-modules/aurelia-event-aggregator.js
+++ b/dist/native-modules/aurelia-event-aggregator.js
@@ -21,6 +21,22 @@ var Handler = function () {
return Handler;
}();
+function invokeCallback(callback, data, event) {
+ try {
+ callback(data, event);
+ } catch (e) {
+ logger.error(e);
+ }
+}
+
+function invokeHandler(handler, data) {
+ try {
+ handler.handle(data);
+ } catch (e) {
+ logger.error(e);
+ }
+}
+
export var EventAggregator = function () {
function EventAggregator() {
@@ -43,24 +59,16 @@ export var EventAggregator = function () {
subscribers = subscribers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i](data, event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeCallback(subscribers[i], data, event);
}
}
} else {
subscribers = this.messageHandlers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i].handle(event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeHandler(subscribers[i], event);
}
}
};
diff --git a/dist/system/aurelia-event-aggregator.js b/dist/system/aurelia-event-aggregator.js
index ae2f53f..60fec73 100644
--- a/dist/system/aurelia-event-aggregator.js
+++ b/dist/system/aurelia-event-aggregator.js
@@ -7,6 +7,22 @@ System.register(['aurelia-logging'], function (_export, _context) {
+ function invokeCallback(callback, data, event) {
+ try {
+ callback(data, event);
+ } catch (e) {
+ logger.error(e);
+ }
+ }
+
+ function invokeHandler(handler, data) {
+ try {
+ handler.handle(data);
+ } catch (e) {
+ logger.error(e);
+ }
+ }
+
function includeEventsIn(obj) {
var ea = new EventAggregator();
@@ -79,24 +95,16 @@ System.register(['aurelia-logging'], function (_export, _context) {
subscribers = subscribers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i](data, event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeCallback(subscribers[i], data, event);
}
}
} else {
subscribers = this.messageHandlers.slice();
i = subscribers.length;
- try {
- while (i--) {
- subscribers[i].handle(event);
- }
- } catch (e) {
- logger.error(e);
+ while (i--) {
+ invokeHandler(subscribers[i], event);
}
}
};
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index b17800b..3cdaf17 100644
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,3 +1,13 @@
+
+## [1.0.1](https://github.com/aurelia/event-aggregator/compare/1.0.0...v1.0.1) (2016-12-03)
+
+
+### Bug Fixes
+
+* **index:** handle errors per callback invocation ([dc7819f](https://github.com/aurelia/event-aggregator/commit/dc7819f))
+
+
+
# [1.0.0](https://github.com/aurelia/event-aggregator/compare/1.0.0-rc.1.0.0...v1.0.0) (2016-07-27)
diff --git a/package.json b/package.json
index 3baa717..dc8112a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "aurelia-event-aggregator",
- "version": "1.0.0",
+ "version": "1.0.1",
"description": "A lightweight pub/sub messaging system for app-wide or per-object loosely coupled events.",
"keywords": [
"aurelia",