I am loading about 2MB of JSON data from my server, and then persisting that locally using LocalStorage.
The code is fairly simple. It does an add() on the local store for each record retrieved from the server.
Then I perform a sync().
Since this is a large data set, the actual batch insert operations seem to take up to 30 seconds (however, it's async so I don't see the delay on the application).
What I am finding is that in Safari, the sync() is happening in the background (I know this because the process safari.exe process keeps running until the sync() is complete, which is good). If I kill the safari.exe process, I seem to corrupt my localstorage.
However, I find that with the iPad when the web app is "installed" to the spring board, pressing the Home button seems to kill my process, and will also corrupti my datastore.
In contrast, if I run my app in Safari on the iPad, since the Safari process is always running, I don't seem to hit this issue.
My question: Is there a callback to know when sync() is complete, so at least I can show a progress panel during this 30 seconds?
Or is there a way I can take over and control the proxy to insert non-batched? I'm thinking something like REST, but for localstorage.