Skip to content
Permalink
Browse files
Little code simplification
  • Loading branch information
mweststrate committed Mar 1, 2017
1 parent 670c916 commit fd5658b924e851a33bd0f9e3786dc934c3ddfe52
Showing 1 changed file with 22 additions and 24 deletions.
@@ -161,35 +161,33 @@ const observablePropertyConfigs = {};
const computedPropertyConfigs = {};

export function generateObservablePropConfig(propName) {
const config = observablePropertyConfigs[propName];
if (config)
return config;
return observablePropertyConfigs[propName] = {
configurable: true,
enumerable: true,
get: function() {
return this.$mobx.values[propName].get();
},
set: function(v) {
setPropertyValue(this, propName, v);
return observablePropertyConfigs[propName] || (
observablePropertyConfigs[propName] = {
configurable: true,
enumerable: true,
get: function() {
return this.$mobx.values[propName].get();
},
set: function(v) {
setPropertyValue(this, propName, v);
}
}
};
);
}

export function generateComputedPropConfig(propName) {
const config = computedPropertyConfigs[propName];
if (config)
return config;
return computedPropertyConfigs[propName] = {
configurable: true,
enumerable: false,
get: function() {
return this.$mobx.values[propName].get();
},
set: function(v) {
return this.$mobx.values[propName].set(v);
return computedPropertyConfigs[propName] || (
computedPropertyConfigs[propName] = {
configurable: true,
enumerable: false,
get: function() {
return this.$mobx.values[propName].get();
},
set: function(v) {
return this.$mobx.values[propName].set(v);
}
}
};
);
}

export function setPropertyValue(instance, name: string, newValue) {

0 comments on commit fd5658b

Please sign in to comment.