I'm having a heck of a time to execute functions in the background. I have one function that queries an external json file and the loops through it and inserts around 150 records into an sqlite database and it literally takes 30 seconds to do and while it's running the app is entirely useless (freezes).
I've tried the jquery async loop plugin and it works though navigating the app while its running is extremely slow / choppy.
Is there no titanium function that allows me to execute a function in the background that doesn't affect the rest of the app?
This is driving me nuts, without this my app is beyond useless :(
While Titanium Mobile doesn't have proper backgrounding, there are a couple of things you can try….
Create a new window and execute it in that, each window has it's own context so it might not interfere with your current display context. You can let you main UI window know that it's done by an event.
Fire an event and have your other item listen for it, being as events are fired asynchronously they provide you with some level of backgrounding.
I'm not sure if you are able to do this but what I would recommend is getting a smaller amount of data from the json file.
Then, paginate the data when displayed (similar to the app store how you scroll down). I would even prefetch the data so the user doesn't notice the loads.