Skip to content

Instantly share code, notes, and snippets.

@stephen
Created December 9, 2014 23:50
Show Gist options
  • Save stephen/4d8f3ce04fb2a2d5f389 to your computer and use it in GitHub Desktop.
Save stephen/4d8f3ce04fb2a2d5f389 to your computer and use it in GitHub Desktop.
static createProxyFromModel(model) {
return new Proxy(model, {
get: function(target, name) {
if (name in model.definition) {
return model.get(name);
} else {
return target[name];
}
},
set: function(target, name, value) {
if (name in model.definition) {
model.set(name, value);
} else {
target[name] = value;
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment