Skip to content

Instantly share code, notes, and snippets.

@meftunca
Last active July 10, 2019 18:54
Show Gist options
  • Save meftunca/67b168fafd0d2b671cd5ae8a65adb1d0 to your computer and use it in GitHub Desktop.
Save meftunca/67b168fafd0d2b671cd5ae8a65adb1d0 to your computer and use it in GitHub Desktop.
export default listenerFunc => {
Object.defineProperty(window.globalStore, "onChangeListener", {
value: listenerFunc
});
};
let Person = {
name: "test",
age: "12"
}
window.globalStore = new Proxy(
person,
{
get: function(target, value, r) {
return value in target ? target[value] : undefined;
},
set: function(target, key, value, r) {
target[key] = value;
r.onChangeListener({ [key]: value });
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment