From 9cdcecd046d77c5341f4b792825c26e7f9c01620 Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Tue, 6 Jan 2015 09:32:03 -0500 Subject: [PATCH] chore(all): prepare release 0.2.0 --- bower.json | 2 +- dist/amd/index.js | 111 ++++++++++++++++++++--------------------- dist/commonjs/index.js | 111 ++++++++++++++++++++--------------------- dist/es6/index.js | 4 ++ dist/system/index.js | 94 ++++++++++++++++++++++++++++++++++ doc/CHANGELOG.md | 13 +++++ doc/api.json | 2 +- package.json | 2 +- 8 files changed, 222 insertions(+), 117 deletions(-) create mode 100644 dist/system/index.js create mode 100644 doc/CHANGELOG.md diff --git a/bower.json b/bower.json index 5e8f4a2..9bbd89f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "aurelia-event-aggregator", - "version": "0.1.1", + "version": "0.2.0", "description": "A lightweight pub/sub messaging system for app-wide or per-object loosely coupled events.", "keywords": [ "aurelia", diff --git a/dist/amd/index.js b/dist/amd/index.js index 38629cc..47c0e87 100644 --- a/dist/amd/index.js +++ b/dist/amd/index.js @@ -2,75 +2,68 @@ define(["exports"], function (exports) { "use strict"; exports.includeEventsIn = includeEventsIn; - var Handler = (function () { - var Handler = function Handler(messageType, callback) { - this.messageType = messageType; - this.callback = callback; - }; - - Handler.prototype.handle = function (message) { - if (message instanceof this.messageType) { - this.callback.call(null, message); - } - }; - - return Handler; - })(); - - var EventAggregator = (function () { - var EventAggregator = function EventAggregator() { - this.eventLookup = {}; - this.messageHandlers = []; - }; - - EventAggregator.prototype.publish = function (event, data) { - var subscribers, i, handler; - - if (typeof event === "string") { - subscribers = this.eventLookup[event]; - if (subscribers) { - subscribers = subscribers.slice(); - i = subscribers.length; - - while (i--) { - subscribers[i](data, event); - } - } - } else { - subscribers = this.messageHandlers.slice(); + exports.install = install; + var Handler = function Handler(messageType, callback) { + this.messageType = messageType; + this.callback = callback; + }; + + Handler.prototype.handle = function (message) { + if (message instanceof this.messageType) { + this.callback.call(null, message); + } + }; + + var EventAggregator = function EventAggregator() { + this.eventLookup = {}; + this.messageHandlers = []; + }; + + EventAggregator.prototype.publish = function (event, data) { + var subscribers, i, handler; + + if (typeof event === "string") { + subscribers = this.eventLookup[event]; + if (subscribers) { + subscribers = subscribers.slice(); i = subscribers.length; while (i--) { - subscribers[i].handle(event); + subscribers[i](data, event); } } - }; + } else { + subscribers = this.messageHandlers.slice(); + i = subscribers.length; - EventAggregator.prototype.subscribe = function (event, callback) { - var subscribers, handler; + while (i--) { + subscribers[i].handle(event); + } + } + }; - if (typeof event === "string") { - subscribers = this.eventLookup[event] || (this.eventLookup[event] = []); + EventAggregator.prototype.subscribe = function (event, callback) { + var subscribers, handler; - subscribers.push(callback); + if (typeof event === "string") { + subscribers = this.eventLookup[event] || (this.eventLookup[event] = []); - return function () { - subscribers.splice(subscribers.indexOf(callback), 1); - }; - } else { - handler = new Handler(event, callback); - subscribers = this.messageHandlers; + subscribers.push(callback); - subscribers.push(handler); + return function () { + subscribers.splice(subscribers.indexOf(callback), 1); + }; + } else { + handler = new Handler(event, callback); + subscribers = this.messageHandlers; - return function () { - subscribers.splice(subscribers.indexOf(handler), 1); - }; - } - }; + subscribers.push(handler); - return EventAggregator; - })(); + return function () { + subscribers.splice(subscribers.indexOf(handler), 1); + }; + } + }; exports.EventAggregator = EventAggregator; function includeEventsIn(obj) { @@ -86,4 +79,8 @@ define(["exports"], function (exports) { return ea; } + + function install(aurelia) { + aurelia.withInstance(EventAggregator, includeEventsIn(aurelia)); + } }); \ No newline at end of file diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js index 5e089fd..97ce8af 100644 --- a/dist/commonjs/index.js +++ b/dist/commonjs/index.js @@ -1,75 +1,68 @@ "use strict"; exports.includeEventsIn = includeEventsIn; -var Handler = (function () { - var Handler = function Handler(messageType, callback) { - this.messageType = messageType; - this.callback = callback; - }; - - Handler.prototype.handle = function (message) { - if (message instanceof this.messageType) { - this.callback.call(null, message); - } - }; - - return Handler; -})(); - -var EventAggregator = (function () { - var EventAggregator = function EventAggregator() { - this.eventLookup = {}; - this.messageHandlers = []; - }; - - EventAggregator.prototype.publish = function (event, data) { - var subscribers, i, handler; - - if (typeof event === "string") { - subscribers = this.eventLookup[event]; - if (subscribers) { - subscribers = subscribers.slice(); - i = subscribers.length; - - while (i--) { - subscribers[i](data, event); - } - } - } else { - subscribers = this.messageHandlers.slice(); +exports.install = install; +var Handler = function Handler(messageType, callback) { + this.messageType = messageType; + this.callback = callback; +}; + +Handler.prototype.handle = function (message) { + if (message instanceof this.messageType) { + this.callback.call(null, message); + } +}; + +var EventAggregator = function EventAggregator() { + this.eventLookup = {}; + this.messageHandlers = []; +}; + +EventAggregator.prototype.publish = function (event, data) { + var subscribers, i, handler; + + if (typeof event === "string") { + subscribers = this.eventLookup[event]; + if (subscribers) { + subscribers = subscribers.slice(); i = subscribers.length; while (i--) { - subscribers[i].handle(event); + subscribers[i](data, event); } } - }; + } else { + subscribers = this.messageHandlers.slice(); + i = subscribers.length; - EventAggregator.prototype.subscribe = function (event, callback) { - var subscribers, handler; + while (i--) { + subscribers[i].handle(event); + } + } +}; - if (typeof event === "string") { - subscribers = this.eventLookup[event] || (this.eventLookup[event] = []); +EventAggregator.prototype.subscribe = function (event, callback) { + var subscribers, handler; - subscribers.push(callback); + if (typeof event === "string") { + subscribers = this.eventLookup[event] || (this.eventLookup[event] = []); - return function () { - subscribers.splice(subscribers.indexOf(callback), 1); - }; - } else { - handler = new Handler(event, callback); - subscribers = this.messageHandlers; + subscribers.push(callback); - subscribers.push(handler); + return function () { + subscribers.splice(subscribers.indexOf(callback), 1); + }; + } else { + handler = new Handler(event, callback); + subscribers = this.messageHandlers; - return function () { - subscribers.splice(subscribers.indexOf(handler), 1); - }; - } - }; + subscribers.push(handler); - return EventAggregator; -})(); + return function () { + subscribers.splice(subscribers.indexOf(handler), 1); + }; + } +}; exports.EventAggregator = EventAggregator; function includeEventsIn(obj) { @@ -84,4 +77,8 @@ function includeEventsIn(obj) { }; return ea; +} + +function install(aurelia) { + aurelia.withInstance(EventAggregator, includeEventsIn(aurelia)); } \ No newline at end of file diff --git a/dist/es6/index.js b/dist/es6/index.js index 8d7a3d4..b0a8b91 100644 --- a/dist/es6/index.js +++ b/dist/es6/index.js @@ -76,4 +76,8 @@ export function includeEventsIn(obj){ }; return ea; +} + +export function install(aurelia){ + aurelia.withInstance(EventAggregator, includeEventsIn(aurelia)); } \ No newline at end of file diff --git a/dist/system/index.js b/dist/system/index.js new file mode 100644 index 0000000..dca4efc --- /dev/null +++ b/dist/system/index.js @@ -0,0 +1,94 @@ +System.register([], function (_export) { + "use strict"; + + var Handler, EventAggregator; + _export("includeEventsIn", includeEventsIn); + + _export("install", install); + + function includeEventsIn(obj) { + var ea = new EventAggregator(); + + obj.subscribe = function (event, callback) { + return ea.subscribe(event, callback); + }; + + obj.publish = function (event, data) { + ea.publish(event, data); + }; + + return ea; + } + + function install(aurelia) { + aurelia.withInstance(EventAggregator, includeEventsIn(aurelia)); + } + return { + setters: [], + execute: function () { + Handler = function Handler(messageType, callback) { + this.messageType = messageType; + this.callback = callback; + }; + + Handler.prototype.handle = function (message) { + if (message instanceof this.messageType) { + this.callback.call(null, message); + } + }; + + EventAggregator = function EventAggregator() { + this.eventLookup = {}; + this.messageHandlers = []; + }; + + EventAggregator.prototype.publish = function (event, data) { + var subscribers, i, handler; + + if (typeof event === "string") { + subscribers = this.eventLookup[event]; + if (subscribers) { + subscribers = subscribers.slice(); + i = subscribers.length; + + while (i--) { + subscribers[i](data, event); + } + } + } else { + subscribers = this.messageHandlers.slice(); + i = subscribers.length; + + while (i--) { + subscribers[i].handle(event); + } + } + }; + + EventAggregator.prototype.subscribe = function (event, callback) { + var subscribers, handler; + + if (typeof event === "string") { + subscribers = this.eventLookup[event] || (this.eventLookup[event] = []); + + subscribers.push(callback); + + return function () { + subscribers.splice(subscribers.indexOf(callback), 1); + }; + } else { + handler = new Handler(event, callback); + subscribers = this.messageHandlers; + + subscribers.push(handler); + + return function () { + subscribers.splice(subscribers.indexOf(handler), 1); + }; + } + }; + + _export("EventAggregator", EventAggregator); + } + }; +}); \ No newline at end of file diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md new file mode 100644 index 0000000..26b6864 --- /dev/null +++ b/doc/CHANGELOG.md @@ -0,0 +1,13 @@ +## 0.2.0 (2015-01-06) + + +#### Bug Fixes + +* **index:** remove invalid character ([96642658](http://github.com/aurelia/event-aggregator/commit/96642658caf7d90733a0e103980841ccbbc43eb8)) + + +#### Features + +* **build:** update compiler and switch to register module format ([302c2870](http://github.com/aurelia/event-aggregator/commit/302c287092d9812a3d2c7e5fca2c1bb20618fffc)) +* **event-aggregator:** enable plugin usage ([2c597329](http://github.com/aurelia/event-aggregator/commit/2c5973292dbd5087325226298ae966b1dcb7ac17)) + diff --git a/doc/api.json b/doc/api.json index b648957..6de3c0a 100644 --- a/doc/api.json +++ b/doc/api.json @@ -1 +1 @@ -{"project":{},"files":{},"modules":{},"classes":{},"classitems":[],"warnings":[]} \ No newline at end of file +{"classes":[],"methods":[],"properties":[],"events":[]} \ No newline at end of file diff --git a/package.json b/package.json index 0bfeec9..6d0340b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-event-aggregator", - "version": "0.1.1", + "version": "0.2.0", "description": "A lightweight pub/sub messaging system for app-wide or per-object loosely coupled events.", "keywords": [ "aurelia",