Remove uses of for-of loops in RPC modules

The React Native packager does not transform for-of loops, and minification step uses UglifyJS, which does not yet support ES6 syntax.

Fixes #120
This commit is contained in:
Scott Kyle 2015-11-05 16:10:52 -08:00
parent 54b94b6afa
commit 336ef55c1f
4 changed files with 9 additions and 10 deletions

View File

@ -4,6 +4,9 @@
"browser": true, "browser": true,
"es6": true, "es6": true,
}, },
"ecmaFeatures": {
"forOf": false
},
"globals": { "globals": {
"global": true "global": true
} }

View File

@ -25,14 +25,14 @@ function create(realmId, info) {
object[keys.id] = info.id; object[keys.id] = info.id;
object[keys.type] = info.type; object[keys.type] = info.type;
for (let prop of schema.properties) { schema.properties.forEach((prop) => {
let name = prop.name; let name = prop.name;
props[name] = { props[name] = {
get: util.getterForProperty(name), get: util.getterForProperty(name),
set: util.setterForProperty(name), set: util.setterForProperty(name),
}; };
} });
Object.defineProperties(object, props); Object.defineProperties(object, props);

View File

@ -101,9 +101,7 @@ class Realm {
rpc.commitTransaction(realmId); rpc.commitTransaction(realmId);
for (let callback of this[listenersKey]) { this[listenersKey].forEach((cb) => cb(this, 'change'));
callback(this, 'change');
}
} }
} }

View File

@ -28,9 +28,7 @@ function addMutationListener(realmId, callback) {
function fireMutationListeners(realmId) { function fireMutationListeners(realmId) {
let listeners = mutationListeners[realmId]; let listeners = mutationListeners[realmId];
if (listeners) { if (listeners) {
for (let callback of listeners) { listeners.forEach((cb) => cb());
callback();
}
} }
} }
@ -97,11 +95,11 @@ function createList(prototype, realmId, info, mutable) {
function createMethods(prototype, type, methodNames, mutates) { function createMethods(prototype, type, methodNames, mutates) {
let props = {}; let props = {};
for (let name of methodNames) { methodNames.forEach((name) => {
props[name] = { props[name] = {
value: createMethod(type, name, mutates), value: createMethod(type, name, mutates),
}; };
} });
Object.defineProperties(prototype, props); Object.defineProperties(prototype, props);
} }