Created
September 13, 2018 13:50
-
-
Save skipme/eba05ab3c756b456eb28145142f0d4fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createSettersProxy(string_name, object_setters, function_proxy) | |
{ | |
Object.keys(object_setters).forEach((property) => { | |
let descriptor = Object.getOwnPropertyDescriptor(object_setters, property); | |
if (typeof descriptor.set === 'function' | |
&& property.indexOf("_orig_") < 0) | |
{ | |
// console.log("set is ", property); | |
let pxy_name = property +"_orig_"; | |
if(!object_setters.hasOwnProperty(pxy_name)) | |
{ | |
Object.defineProperty(object_setters, pxy_name, descriptor); | |
} | |
let prop_path = string_name+"."+property; | |
let allows_get = typeof descriptor.get === 'function'; | |
let proxy_f = function(v) | |
{ | |
function_proxy(prop_path, v, true);// PROXY SPEC SET | |
object_setters[pxy_name] = v; | |
if(allows_get) | |
{ | |
function_proxy(prop_path, descriptor.get(), false);// PROXY SPEC GET | |
} | |
}; | |
Object.defineProperty(object_setters, property, {set: proxy_f}); | |
if(allows_get) | |
{ | |
function_proxy(prop_path, descriptor.get(), false); | |
} | |
} | |
}); | |
} | |
for (var k in this.$scope) | |
{ | |
if(typeof this.$scope[k] === "object") | |
{ | |
createSettersProxy(k, this.$scope[k], function(p, v, ch){ $setter_proxy(p, v, ch); }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment