{"ScriptPreparationCode":"data1 = {};\r\nhandler = {\r\n get: (target, prop) =\u003E (target[prop]),\r\n set: (target, prop, value) =\u003E console.error(\u0022IMMUTABLE!!!\u0022),\r\n};\r\nproxy = new Proxy(data1, handler);\r\ndata2 = {\r\n get test() {\r\n return this._test;\r\n },\r\n set test(value) {\r\n return this._test = value;\r\n }\r\n};\r\nconst EVENTS = new WeakMap();\r\nfunction pub(object, event, data) {\r\n if (!EVENTS.has(object)) { return; }\r\n const callbacks = EVENTS.get(object)[event];\r\n if (callbacks) {\r\n for (const callback of callbacks) {\r\n callback(data);\r\n }\r\n }\r\n}\r\nfunction sub(object, event, callback) {\r\n let dict;\r\n if (!EVENTS.has(object)) {\r\n EVENTS.set(object, dict={});\r\n } else {\r\n dict = EVENTS.get(object);\r\n }\r\n let evList;\r\n if (event in dict) {\r\n (evList = dict[event]).push(callback);\r\n } else {\r\n evList = dict[event] = [callback];\r\n }\r\n return function unsub() {\r\n evList.splice(evList.indexOf(callback), 1);\r\n }\r\n}\r\ndata3 = {};\r\nsub(data3, \u0027set-test\u0027, v =\u003E data3.test = v);\r\nsub(data3, \u0027get-test\u0027, () =\u003E pub(data3, \u0027getting-test\u0027, data3.test));\r\nsub(data3, \u0027getting-test\u0027, v =\u003E a \u002B= v);\r\nvar a = 0;\r\ndata4 = {};\r\ndata5 = {};\r\nsub(data5, \u0027set-test\u0027, v =\u003E { data5.test = v; pub(data5, \u0027getting-test\u0027, data3.test); });\r\nsub(data5, \u0027getting-test\u0027, v =\u003E a \u002B= v);","TestCases":[{"Name":"getter / setter","Code":"data2.test = Math.random();\r\na \u002B= data2.test;","IsDeferred":false},{"Name":"proxy","Code":"proxy.test = Math.random();\r\na \u002B= proxy.test;","IsDeferred":false},{"Name":"events","Code":"pub(data3, \u0027set-test\u0027, Math.random());\r\npub(data3, \u0027get-test\u0027);","IsDeferred":false},{"Name":"plain object","Code":"data4.test = Math.random();\r\na \u002B= data4.test;","IsDeferred":false},{"Name":"events (kinda cheating)","Code":"// note that is almost certainly not accurate since it probably ends after this function is called, not when getting-test triggers\r\npub(data3, \u0027set-test\u0027, Math.random());","IsDeferred":false}]}