Skip to content

Instantly share code, notes, and snippets.

@rajatjain-21
Created September 9, 2020 11:28
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 rajatjain-21/27ac829b7accf1efb406aa63a00c323e to your computer and use it in GitHub Desktop.
Save rajatjain-21/27ac829b7accf1efb406aa63a00c323e to your computer and use it in GitHub Desktop.
// Function to be called on click
const mainFunc = () => {
console.log("Called me?😃");
}
const oncifyHelper = () => {
let clickCount = 0;
const oncifyHelperInner = (func) => {
if(clickCount===0) {
func();
clickCount++;
} else {
console.log("Limit Reached. Sorry😐")
}
}
return oncifyHelperInner;
}
// The main oncify function
const oncify = oncifyHelper();
oncify(mainFunc)
oncify(mainFunc)
oncify(mainFunc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment