From ef2903bf5112810f1aae24cdf16aee6a4c66776d Mon Sep 17 00:00:00 2001 From: Rob Eisenberg Date: Thu, 9 Apr 2015 01:57:04 -0400 Subject: [PATCH] chore(all): prepare release 0.3.0 --- bower.json | 2 +- dist/amd/index.js | 132 +++++++++++++++++++++-------------------- dist/commonjs/index.js | 132 +++++++++++++++++++++-------------------- dist/es6/index.js | 14 ++++- dist/system/index.js | 131 ++++++++++++++++++++-------------------- doc/CHANGELOG.md | 13 ++++ package.json | 2 +- 7 files changed, 227 insertions(+), 199 deletions(-) diff --git a/bower.json b/bower.json index 87fd889..f799a7c 100644 --- a/bower.json +++ b/bower.json @@ -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", diff --git a/dist/amd/index.js b/dist/amd/index.js index 79cf8fc..52be563 100644 --- a/dist/amd/index.js +++ b/dist/amd/index.js @@ -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; @@ -16,22 +19,19 @@ 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); @@ -39,64 +39,70 @@ define(["exports"], function (exports) { 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(); @@ -114,8 +120,4 @@ define(["exports"], function (exports) { function install(aurelia) { aurelia.withInstance(EventAggregator, includeEventsIn(aurelia)); } - - Object.defineProperty(exports, "__esModule", { - value: true - }); }); \ No newline at end of file diff --git a/dist/commonjs/index.js b/dist/commonjs/index.js index 24bee91..8f14af8 100644 --- a/dist/commonjs/index.js +++ b/dist/commonjs/index.js @@ -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; @@ -15,22 +18,19 @@ 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); @@ -38,64 +38,70 @@ var EventAggregator = exports.EventAggregator = (function () { 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(); @@ -112,8 +118,4 @@ function includeEventsIn(obj) { function install(aurelia) { aurelia.withInstance(EventAggregator, includeEventsIn(aurelia)); -} - -Object.defineProperty(exports, "__esModule", { - value: true -}); \ No newline at end of file +} \ No newline at end of file diff --git a/dist/es6/index.js b/dist/es6/index.js index b0a8b91..14e323f 100644 --- a/dist/es6/index.js +++ b/dist/es6/index.js @@ -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]; @@ -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); }; @@ -80,4 +88,4 @@ export function includeEventsIn(obj){ 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 index 504e792..84d9724 100644 --- a/dist/system/index.js +++ b/dist/system/index.js @@ -1,9 +1,9 @@ System.register([], function (_export) { - var _prototypeProperties, _classCallCheck, Handler, EventAggregator; + var _classCallCheck, _createClass, Handler, EventAggregator; - _export("includeEventsIn", includeEventsIn); + _export('includeEventsIn', includeEventsIn); - _export("install", install); + _export('install', install); function includeEventsIn(obj) { var ea = new EventAggregator(); @@ -26,11 +26,11 @@ System.register([], function (_export) { return { setters: [], execute: function () { - "use strict"; + 'use strict'; - _prototypeProperties = function (child, staticProps, instanceProps) { if (staticProps) Object.defineProperties(child, staticProps); if (instanceProps) Object.defineProperties(child.prototype, instanceProps); }; + _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }; - _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; + _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; }; })(); Handler = (function () { function Handler(messageType, callback) { @@ -40,22 +40,19 @@ System.register([], function (_export) { 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; })(); - EventAggregator = _export("EventAggregator", (function () { + EventAggregator = (function () { function EventAggregator() { _classCallCheck(this, EventAggregator); @@ -63,63 +60,69 @@ System.register([], function (_export) { this.messageHandlers = []; } - _prototypeProperties(EventAggregator, null, { - publish: { - value: function publish(event, data) { - var subscribers, i, handler; - - if (typeof event === "string") { - subscribers = this.eventLookup[event]; - if (subscribers) { - subscribers = subscribers.slice(); - i = subscribers.length; + _createClass(EventAggregator, [{ + key: 'publish', + value: function publish(event, data) { + var subscribers, i; - 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; - })()); + })(); + + _export('EventAggregator', EventAggregator); } }; }); \ No newline at end of file diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 8e0a7e9..2736722 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,16 @@ +## 0.3.0 (2015-04-09) + + +#### Bug Fixes + +* **all:** upgrade to latest compiler ([ae84b313](http://github.com/aurelia/event-aggregator/commit/ae84b3139c1cc906614a904d78935e06a7959fde)) + + +#### Features + +* **event-aggregator:** subscribeOnce function ([076264e7](http://github.com/aurelia/event-aggregator/commit/076264e7ffc2bcec090b4c4339671262ffb8238d)) + + ### 0.2.4 (2015-02-28) diff --git a/package.json b/package.json index 5743333..6923b1c 100644 --- a/package.json +++ b/package.json @@ -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",