Hi
I have a function that is triggered by an event and within this function there are several sub-functions that are called.
The first sub-functions makes use of some "zo_callLater" and the end of this sub-function is reached earlier than all the "zo_callLater" are ended (they might take 2-3 seconds). So the second sub-function is already called although not all "zo_callLater" from the first sub-function have ended, which causes some problems in the addon.
Currently I deal with this situation in the following way:
The first sub-function returns "true" as soon as all "zo_callLater" calls are completed. I then check this value in a loop if it is "true" and only in that case allow the main function to call the second sub-function.
Lua Code:
local mainFunction()
-- call the first sub-function that contains some 'zo_callLater'
local isCompleted = callFirstSubFunction()
while (isCompleted == nil) do
-- do nothing; wait
end
-- call the second sub-function
callAnotherSubFunction()
end
It basically works, but I am not sure how bad (performance-wise) this solution is.
I don't see any game-freezing effects like a regular endless-loop would cause, but I thought there might be a better solution for this?
Klingo