callback question

I am having some trouble understanding callbacks or closures. I am trying to sort a large data set and I want to display a spinner while the data is being processed.

Essentially I am trying to do something like this, but the table.sort function doesn’t block. How do I watch for the sort function to be complete so I can stop the spinner? Thanks,

local function sortTable( sortFunction) startSpinner( x, y, group ) table.sort( list, sortFunction ) stopSpinner() end

if the sort is very quick then you are doing this just for look and feel?

or is the sort kind of slow?

How about trying to call the performWithDelay() so the spinner has a chance to show, not sure how to get the call to stop spinning .

Maybe you could call stop spinner after 2 or 3 seconds etc…

local function sortTable( sortFunction)     startSpinner( x, y, group );   --Sort     dTimer = timer.performWithDelay( 1000, table.sort( list, sortFunction ), 1 ); --Stop spinner in 3 seconds dTimer = timer.performWithDelay( 3000, table.sort( list, stopSpinner(); ), 1 );   end

Good luck larry

if the sort is very quick then you are doing this just for look and feel?

or is the sort kind of slow?

How about trying to call the performWithDelay() so the spinner has a chance to show, not sure how to get the call to stop spinning .

Maybe you could call stop spinner after 2 or 3 seconds etc…

local function sortTable( sortFunction)     startSpinner( x, y, group );   --Sort     dTimer = timer.performWithDelay( 1000, table.sort( list, sortFunction ), 1 ); --Stop spinner in 3 seconds dTimer = timer.performWithDelay( 3000, table.sort( list, stopSpinner(); ), 1 );   end

Good luck larry