Created
September 9, 2020 11:28
-
-
Save rajatjain-21/27ac829b7accf1efb406aa63a00c323e to your computer and use it in GitHub Desktop.
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
// 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