summaryrefslogtreecommitdiffstats
path: root/js/service
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-22 01:03:27 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-22 01:03:27 +0200
commitbf52ed4a0aedaf440733147e5e7fb086d16e9841 (patch)
treef23542228f2d6e8d6e647c6e4788f6fa52e45cdc /js/service
parent295adcbef7618f4a0b4781c92e4b1c32b31a5f36 (diff)
add generators to iterate over objects
Diffstat (limited to 'js/service')
-rw-r--r--js/service/Publisher.js4
-rw-r--r--js/service/Resource.js14
-rw-r--r--js/service/Settings.js4
3 files changed, 10 insertions, 12 deletions
diff --git a/js/service/Publisher.js b/js/service/Publisher.js
index b6ea722ce..d4efa4a80 100644
--- a/js/service/Publisher.js
+++ b/js/service/Publisher.js
@@ -25,10 +25,10 @@ app.service('Publisher', function () {
};
this.publishAll = (data) => {
- for (let channel in data) {
+ for (let [channel, messages] of items(data)) {
if (this.channels[channel] !== undefined) {
for (let listener of this.channels[channel]) {
- listener.receive(data[channel], channel);
+ listener.receive(messages, channel);
}
}
}
diff --git a/js/service/Resource.js b/js/service/Resource.js
index 3c17872dc..832b9d791 100644
--- a/js/service/Resource.js
+++ b/js/service/Resource.js
@@ -25,18 +25,16 @@ app.factory('Resource', () => {
});
}
- add (value) {
- let existing = this.hashMap[value[this.id]];
+ add (obj) {
+ let existing = this.hashMap[obj[this.id]];
if (existing === undefined) {
- this.values.push(value);
- this.hashMap[value[this.id]] = value;
+ this.values.push(obj);
+ this.hashMap[obj[this.id]] = obj;
} else {
// copy values from new to old object if it exists already
- for (let key in value) {
- if (value.hasOwnProperty(key)) {
- existing[key] = value[key];
- }
+ for (let [key, value] of items(obj)) {
+ existing[key] = value;
}
}
}
diff --git a/js/service/Settings.js b/js/service/Settings.js
index 61e79b25d..1bc716b07 100644
--- a/js/service/Settings.js
+++ b/js/service/Settings.js
@@ -13,8 +13,8 @@ app.service('Settings', function () {
this.settings = {};
this.receive = (data) => {
- for (let key in data) {
- this.settings[key] = data[key];
+ for (let [key, value] of items(data)) {
+ this.settings[key] = value;
}
};