Stop an 'on' event listener

Is there a way to stop listening to an event set with the 'on' function?
1523825736
Jakob
Pro
Sheet Author
API Scripter
Robin K. said: Is there a way to stop listening to an event set with the 'on' function? Not as far as I'm aware, but you can certainly find a workaround for whatever your use case is, e.g. setting some variable to make the callback function do nothing.
1523866256

Edited 1523866294
G G
Pro
Sheet Author
You should be able to set up a chat command to switch the listener on and off, perhaps with a boolean stored in the state. Then in the on event, have an if statement wrapping your actual process code so that it doesnt actually do anything if the boolean is false. Edit: Ninja'd by Jakob, only by 11 hours...
Thank you for the replies guys! I take a look in to this.