Can we pass in a function argument to a timer CB?
-
I'm trying to find a way to get a function doing something with it's parameter after a delay. Of course, I could have used an external variable, or use a hidden panel timer to benefit from the data object... But in order to keep things tidy and even more for my own knowledge, is it possible to use the parameter from the caller in the timer?
inline function mainFunctionToCall(myParameter) { t.startTimer(1000); } const var t = Engine.createTimerObject(); t.setTimerCallback(function() { this.stopTimer(); // DO SOMETHING WITH myParameter });
In the end, as the code suggests, you see that I just want to delay a function call but use its parameter
-
Can't be done as far as I'm aware
-
@ustk Maybe this? Here are some snippets.
https://forum.hise.audio/topic/7073/wait-for-1-seconds-then-set-the-value/6?_=1687459038297
-
@orange Youhou! Will be testing this asap! Thanks mate!
-
@orange Unfortunately this does not work in ma actual use case.
Because I need to cancel the previous call if a new one has been made in between.Content.callAfterDelay
will execute all previous calls with no way to cancel them.
But since it was not in the question I asked this function perfectly does what it promises :)I'm then relying on a simple timer so I can stop previous call on next one, and use an external variable to copy the parameter. ;)
Unless if it's possible to add a "cancel call" of some sort to the
Content.callAfterDelay
function @Christoph-Hart?