Created
May 17, 2022 10:10
-
-
Save jimfilippou/7cdf3173874801f81ee916fe9d8e0a49 to your computer and use it in GitHub Desktop.
confirmable
This file contains 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
/** | |
* 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