Skip to content

Commit

Permalink
chore(all): prepare release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jan 6, 2015
1 parent 302c287 commit 9cdcecd
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 117 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
111 changes: 54 additions & 57 deletions dist/amd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -86,4 +79,8 @@ define(["exports"], function (exports) {

return ea;
}

function install(aurelia) {
aurelia.withInstance(EventAggregator, includeEventsIn(aurelia));
}
});
111 changes: 54 additions & 57 deletions dist/commonjs/index.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -84,4 +77,8 @@ function includeEventsIn(obj) {
};

return ea;
}

function install(aurelia) {
aurelia.withInstance(EventAggregator, includeEventsIn(aurelia));
}
4 changes: 4 additions & 0 deletions dist/es6/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,8 @@ export function includeEventsIn(obj){
};

return ea;
}

export function install(aurelia){
aurelia.withInstance(EventAggregator, includeEventsIn(aurelia));
}
94 changes: 94 additions & 0 deletions dist/system/index.js
Original file line number Diff line number Diff line change
@@ -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);
}
};
});
13 changes: 13 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))

Loading

0 comments on commit 9cdcecd

Please sign in to comment.