summaryrefslogtreecommitdiffstats
path: root/js/service/Publisher.js
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-09-11 03:55:52 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-09-11 03:55:52 +0200
commitea9ebd4826fe9807af5bc17e786b3dc58f163970 (patch)
tree2894b40614ebe977797cea5745b215e2a2851f61 /js/service/Publisher.js
parent594b92f649d8ed8a705f1af23639463078170d46 (diff)
port to es5 and add es6 shims for object prototypes instead
Diffstat (limited to 'js/service/Publisher.js')
-rw-r--r--js/service/Publisher.js31
1 files changed, 18 insertions, 13 deletions
diff --git a/js/service/Publisher.js b/js/service/Publisher.js
index dd420f629..b5d44c264 100644
--- a/js/service/Publisher.js
+++ b/js/service/Publisher.js
@@ -14,26 +14,31 @@ app.service('Publisher', function () {
this.channels = {};
- this.subscribe = (obj) => {
+ this.subscribe = function (obj) {
+ var self = this;
+
return {
- toChannels: (...channels) => {
- for (let channel of channels) {
- this.channels[channel] = this.channels[channel] || [];
- this.channels[channel].push(obj);
- }
+ toChannels: function (channels) {
+ channels.forEach(function (channel) {
+ self.channels[channel] = self.channels[channel] || [];
+ self.channels[channel].push(obj);
+ });
}
};
};
- this.publishAll = (data) => {
- for (let [channel, messages] of items(data)) {
- if (this.channels[channel] !== undefined) {
- for (let listener of this.channels[channel]) {
- listener.receive(messages, channel);
- }
+ this.publishAll = function (data) {
+ var self = this;
+
+ Object.keys(data).forEach(function (channel) {
+ var listeners = self.channels[channel];
+ if (listeners !== undefined) {
+ listeners.forEach(function (listener) {
+ listener.receive(data[channel], channel);
+ });
}
- }
+ });
};
}); \ No newline at end of file