Created
April 13, 2020 14:01
-
-
Save ronsims2/aa351a019c582c7da7ab97a758787c34 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 RocketFunc (payloadFunc, payloadParams, payloadContext) { | |
let launched = false | |
return (params, override) => { | |
if (!launched || override) { | |
launched = true | |
let parms = params ? params : payloadParams | |
return payloadFunc.apply(payloadContext, payloadParams) | |
} | |
} | |
} | |
const rocket = new RocketFunc((x) => console.log(x), [42]) | |
rocket() | |
rocket(1) | |
rocket() | |
console.log(rocket) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment