Skip to content

Commit

Permalink
chore(all): prepare release 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Apr 9, 2015
1 parent ae84b31 commit ef2903b
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 199 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.2.4",
"version": "0.3.0",
"description": "A lightweight pub/sub messaging system for app-wide or per-object loosely coupled events.",
"keywords": [
"aurelia",
Expand Down
132 changes: 67 additions & 65 deletions dist/amd/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
define(["exports"], function (exports) {
"use strict";
define(['exports'], function (exports) {
'use strict';

var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };

var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

Object.defineProperty(exports, '__esModule', {
value: true
});
exports.includeEventsIn = includeEventsIn;
exports.install = install;

Expand All @@ -16,87 +19,90 @@ define(["exports"], function (exports) {
this.callback = callback;
}

_prototypeProperties(Handler, null, {
handle: {
value: function handle(message) {
if (message instanceof this.messageType) {
this.callback.call(null, message);
}
},
writable: true,
configurable: true
_createClass(Handler, [{
key: 'handle',
value: function handle(message) {
if (message instanceof this.messageType) {
this.callback.call(null, message);
}
}
});
}]);

return Handler;
})();

var EventAggregator = exports.EventAggregator = (function () {
var EventAggregator = (function () {
function EventAggregator() {
_classCallCheck(this, EventAggregator);

this.eventLookup = {};
this.messageHandlers = [];
}

_prototypeProperties(EventAggregator, null, {
publish: {
value: function publish(event, data) {
var subscribers, i, handler;
_createClass(EventAggregator, [{
key: 'publish',
value: function publish(event, data) {
var subscribers, i;

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();
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);
}
}
},
writable: true,
configurable: true
},
subscribe: {
value: function subscribe(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);
};
} else {
subscribers = this.messageHandlers.slice();
i = subscribers.length;

while (i--) {
subscribers[i].handle(event);
}
},
writable: true,
configurable: true
}
}
});
}, {
key: 'subscribe',
value: function subscribe(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);
};
}
}
}, {
key: 'subscribeOnce',
value: function subscribeOnce(event, callback) {
var sub = this.subscribe(event, function (data, event) {
sub();
return callback(data, event);
});
return sub;
}
}]);

return EventAggregator;
})();

exports.EventAggregator = EventAggregator;

function includeEventsIn(obj) {
var ea = new EventAggregator();

Expand All @@ -114,8 +120,4 @@ define(["exports"], function (exports) {
function install(aurelia) {
aurelia.withInstance(EventAggregator, includeEventsIn(aurelia));
}

Object.defineProperty(exports, "__esModule", {
value: true
});
});
132 changes: 67 additions & 65 deletions dist/commonjs/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"use strict";
'use strict';

var _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); };
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };

var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } };
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

Object.defineProperty(exports, '__esModule', {
value: true
});
exports.includeEventsIn = includeEventsIn;
exports.install = install;

Expand All @@ -15,87 +18,90 @@ var Handler = (function () {
this.callback = callback;
}

_prototypeProperties(Handler, null, {
handle: {
value: function handle(message) {
if (message instanceof this.messageType) {
this.callback.call(null, message);
}
},
writable: true,
configurable: true
_createClass(Handler, [{
key: 'handle',
value: function handle(message) {
if (message instanceof this.messageType) {
this.callback.call(null, message);
}
}
});
}]);

return Handler;
})();

var EventAggregator = exports.EventAggregator = (function () {
var EventAggregator = (function () {
function EventAggregator() {
_classCallCheck(this, EventAggregator);

this.eventLookup = {};
this.messageHandlers = [];
}

_prototypeProperties(EventAggregator, null, {
publish: {
value: function publish(event, data) {
var subscribers, i, handler;
_createClass(EventAggregator, [{
key: 'publish',
value: function publish(event, data) {
var subscribers, i;

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();
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);
}
}
},
writable: true,
configurable: true
},
subscribe: {
value: function subscribe(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);
};
} else {
subscribers = this.messageHandlers.slice();
i = subscribers.length;

while (i--) {
subscribers[i].handle(event);
}
},
writable: true,
configurable: true
}
}
}, {
key: 'subscribe',
value: function subscribe(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);
};
}
}
}, {
key: 'subscribeOnce',
value: function subscribeOnce(event, callback) {
var sub = this.subscribe(event, function (data, event) {
sub();
return callback(data, event);
});
return sub;
}
});
}]);

return EventAggregator;
})();

exports.EventAggregator = EventAggregator;

function includeEventsIn(obj) {
var ea = new EventAggregator();

Expand All @@ -112,8 +118,4 @@ function includeEventsIn(obj) {

function install(aurelia) {
aurelia.withInstance(EventAggregator, includeEventsIn(aurelia));
}

Object.defineProperty(exports, "__esModule", {
value: true
});
}
14 changes: 11 additions & 3 deletions dist/es6/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class EventAggregator {
}

publish(event, data){
var subscribers, i, handler;
var subscribers, i;

if(typeof event === 'string'){
subscribers = this.eventLookup[event];
Expand Down Expand Up @@ -62,12 +62,20 @@ export class EventAggregator {
};
}
}

subscribeOnce(event, callback){
var sub = this.subscribe(event,function(data,event){
sub();
return callback(data,event);
});
return sub;
}
}

export function includeEventsIn(obj){
var ea = new EventAggregator();

obj.subscribe = function(event, callback){
obj.subscribe = function(event, callback){
return ea.subscribe(event, callback);
};

Expand All @@ -80,4 +88,4 @@ export function includeEventsIn(obj){

export function install(aurelia){
aurelia.withInstance(EventAggregator, includeEventsIn(aurelia));
}
}
Loading

0 comments on commit ef2903b

Please sign in to comment.