PDA

View Full Version : Go direct to proxy and avoid sync() batching



termy21
23 Dec 2010, 2:32 AM
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.

Thanks.

xnakxx
23 Dec 2010, 1:49 PM
look at autosave

http://dev.sencha.com/deploy/touch/docs/?class=Ext.data.Store

not too sure of any performance ramifications tho

fgeorge
26 Dec 2010, 10:06 AM
hi termy21,

Can you please share what you did to save remote JSON to localstorage? using a sample code?

i cant seem to get my head round it as i havent found an examples on this..

thanks