PDA

View Full Version : What is the truth about LocalStorage?



Dave Miller
7 Oct 2013, 9:49 AM
We have been developing a Sencha app using the Safeforce support shown here
http://wiki.developerforce.com/page/Developing_Mobile_Applications_With_Force.com_And_Sencha_Touch_Part_1

It works quite nicely.

We had naively assumed by words like "local storage" that one could just toggle the Store Manager system to save all the (complex) data in the various stores we fill from the server into browser memory, use it offline and then flip back and resync online. This seems very far from the case...

Is there anything at all like what we want to do?
Is there ever anything in Sencha beyond name=value pairs?

Kurt001
7 Oct 2013, 1:45 PM
From what I have read you are not using a proxy to save the data to localStorage.
localStorage is an offline store on you device.
To grab the data online and store them offline, you would need to get the data (e.g. ajax call) and drop them in the store (using proxy localStorage).
And once you want to save them to the server you would grab the data and return them.

Or you can bind the data directly from the server to the store. There you can change them and sync with the server. But you would still need to make them available offline.

LocalStorage is no invention from Sencha, it's shipped by the browser. Sencha supports it just really good.

Dave Miller
7 Oct 2013, 2:05 PM
It seems you have mostly understood my post and then just restated it.
Obviously we read the main data from the server with an ajax proxy.
Obvously localstorage is a device+browser feature which is then wrapped bySencha.

What I had hoped was that such wrapping of the localstorage would facilitate a convenient & transparent switching of the proxy so that data loaded into a Store via the ajax route could be easily moved to localstorage and then back.

Kurt001
8 Oct 2013, 2:12 AM
Did you try:

store.setProxy()
That way you can use the ajax proxy to grap data, then set the proxy to localStorage and ...
But to be honest I would probably use two stores. One with online data (which get written to the second store right away) and one with offline data, which get synced once you have online service.

Kurt001
8 Oct 2013, 2:51 AM
Just found this (http://www.sencha.com/forum/showthread.php?273129-Does-store-proxy-override-all-the-data-in-the-store)