I know Corona executes functions asynchronously, but I have an instance where I want specific functions to fire off first and so on.
I have a button. Tap the button changes the button state to active and executes some sqlite stuff. Here’s an overly-simplified example of what I tried:
local update = function()
db:exec(“more SQL that updates a table”)
end
local save = function()
db:exec(“some SQL that daves data to a table”)
update()
end
local activeButton = function()
myButton:removeSelf()
local activeButton = display.newImage( “location.png”, 50, 50 )
save()
end
local myButton = display.newImage (“location.png”, 50, 50)
myButton:addEventListener( “tap”, activeButton )
To me it looks like Corona will change out the button THEN execute the save function THEN execute the update function.
What actually happens is Corona execute the db functions THEN changes the button state.
The SQL queries are complex enough that there is a noticeable delay between the button tap and the changing of the button state.
All I really want is for Corona to change the button state immediately then execute the SQL.
Any tips or advice will be greatly appreciated.
