aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-10-11 08:15:52 +0800
committerkumavis <aaron@kumavis.me>2017-10-11 08:15:52 +0800
commit7d50a56198f2992e908bc97b871210ec2b52123a (patch)
treebd7f827ab26e58eb9ca9d3ad4fa5cf89d83659fb
parente32d75965f848f8b26868b6476265e61b791c768 (diff)
downloadtangerine-wallet-browser-7d50a56198f2992e908bc97b871210ec2b52123a.tar
tangerine-wallet-browser-7d50a56198f2992e908bc97b871210ec2b52123a.tar.gz
tangerine-wallet-browser-7d50a56198f2992e908bc97b871210ec2b52123a.tar.bz2
tangerine-wallet-browser-7d50a56198f2992e908bc97b871210ec2b52123a.tar.lz
tangerine-wallet-browser-7d50a56198f2992e908bc97b871210ec2b52123a.tar.xz
tangerine-wallet-browser-7d50a56198f2992e908bc97b871210ec2b52123a.tar.zst
tangerine-wallet-browser-7d50a56198f2992e908bc97b871210ec2b52123a.zip
util - add obj-proxy
-rw-r--r--app/scripts/lib/obj-proxy.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/scripts/lib/obj-proxy.js b/app/scripts/lib/obj-proxy.js
new file mode 100644
index 000000000..29ca1269f
--- /dev/null
+++ b/app/scripts/lib/obj-proxy.js
@@ -0,0 +1,19 @@
+module.exports = function createObjectProxy(obj) {
+ let target = obj
+ const proxy = new Proxy({}, {
+ get: (obj, name) => {
+ // intercept setTarget
+ if (name === 'setTarget') return setTarget
+ return target[name]
+ },
+ set: (obj, name, value) => {
+ target[name] = value
+ return true
+ },
+ })
+ return proxy
+
+ function setTarget (obj) {
+ target = obj
+ }
+} \ No newline at end of file