Skip to content

Instantly share code, notes, and snippets.

@ronsims2
Created April 13, 2020 14:01
Show Gist options
  • Save ronsims2/aa351a019c582c7da7ab97a758787c34 to your computer and use it in GitHub Desktop.
Save ronsims2/aa351a019c582c7da7ab97a758787c34 to your computer and use it in GitHub Desktop.
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