Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimfilippou/7cdf3173874801f81ee916fe9d8e0a49 to your computer and use it in GitHub Desktop.
Save jimfilippou/7cdf3173874801f81ee916fe9d8e0a49 to your computer and use it in GitHub Desktop.
confirmable
/**
* TODO: Write
* @param message
* @returns
*/
export default function Confirmable(message: string) {
return function (target: Object, key: string | symbol, descriptor: PropertyDescriptor) {
const original = descriptor.value;
descriptor.value = function (...args: any[]) {
const allow = confirm(message);
if (allow) {
const result = original.apply(this, args);
return result;
} else {
return null;
}
}
return descriptor;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment