Skip to content

Instantly share code, notes, and snippets.

@CreatiCoding
Created August 23, 2019 17:43
Show Gist options
  • Select an option

  • Save CreatiCoding/976182e598b10d8bbb4b368eb29e9545 to your computer and use it in GitHub Desktop.

Select an option

Save CreatiCoding/976182e598b10d8bbb4b368eb29e9545 to your computer and use it in GitHub Desktop.
javascript pure watch
// standard watch
const watch = (obj, key, defalut_value, callback) => {
Object.defineProperty(obj, key, {
get() {
return this._value || defalut_value;
},
set(value) {
this._value = value;
callback(this._current);
},
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment