Created
September 14, 2016 20:22
-
-
Save rendfall/4ec45edd31d162f735b78c906a71c7d8 to your computer and use it in GitHub Desktop.
Use proxy like observer
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
| let object = {}; | |
| object = new Proxy(object, { | |
| set: (o, prop, value) => { | |
| console.warn(`${prop} is set to ${value}`); | |
| o[prop] = value; | |
| }, | |
| get: (o, prop) => { | |
| console.warn(`${prop} is read`); | |
| return o[prop]; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment