Passing parameter to a callback function
When using a callback function with RegisterForEvent, is there a way I can specify a parameter that the callback uses? For example:
Lua Code:
I can't simply pass BarTracker.toggleVisibility(true) as the 3rd parameter since that immediately invokes the function. In JavaScript, I could use bind or the syntax (() => BarTracker.toggleVisibility(true)) since that won't invoke it, but still passes the parameter when the callback is called. Does Lua have something similar? I don't know exactly what this is called so I couldn't find anything on SO. |
EVENT_MANAGER:RegisterForEvent(BarTracker.name, EVENT_ACTION_LAYER_PUSHED, function() BarTracker.toggleVisibility(true) end)
It's basically shorthand for something like below. The only difference is that in the code below, the function has the name TurnOffVisibility, while in the code above, the function is anonymous. Lua Code:
I suppose "function() BarTracker.toggleVisibility(true) end" might be the same as your JavaScript example? Is "(() => BarTracker.toggleVisibility(true))" a function? |
Quote:
Code:
RegisterSomething(function() { |
Thanks! That did the trick.
|
All times are GMT -6. The time now is 08:25 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI