sproutcore / getting-started

sproutcore.com/getting-started
4 stars 3 forks source link

Persistence -- Use SproutCore local storage. #6

Open geojeff opened 11 years ago

geojeff commented 11 years ago

Is it important to showcase SproutCore fixtures, with example todos loaded initially? Or, just remove fixtures altogether and initial app load has no todos?

And how does this fit in with using local storage, if we do use fixtures?

geojeff commented 11 years ago

SproutCore User Defaults Blog Entry: http://blog.sproutcore.com/scuserdefaults-easy-preferences-using-client-side-storage/

Has link to User Defaults demo, demo code, and SproutCore UserDefaults code.

dcporter commented 11 years ago

UserDefaults is easy, effective, convenient, terribly named, et cetera. For the purposes of this, I don't think we need to showcase fixtures at all, and should have a blank list at launch.

Does that mean that this app is going to diverge substantially from the tutorial apps? Is that already the case anyway?

geojeff commented 11 years ago

I agree on removing fixtures.

Once the todomvc version is done, we can take from it enhancements to add back to our getting-started Todos app, e.g. item editing.

dcporter commented 11 years ago

Agreed on the backporting – my thought was that fixtures are appropriate to the tutorial but not to this app, making that a permanent delta.

geojeff commented 11 years ago

@dcporter I see from 2010 mailing list posts that you may have implemented data storage with UserDefaults. Do you have an example for making a custom data source that uses local storage?

dcporter commented 11 years ago

No data source, and nothing fancier than what you'd build out of this: anything you set on SC.userDefaults will be gettable next time the user comes back, including serializable data like [arrays] and {POJSOs}. Bearing in mind that the stored versions won't reflect changes to the objects until the next time you SC.userDefaults.set() them, and so on.

Mind linking me to my old post? I'm curious. =)

geojeff commented 11 years ago

https://groups.google.com/forum/?fromgroups#!msg/sproutcore/IrfRJebGA44/xgeBCb4Qmn8J

dcporter commented 11 years ago

Ah yes. I never implemented what I was discussing there. userDefaults can't handle SproutCore objects (ergo records), but it can handle arrays and plain objects, so serializing from this app's simple data model into userDefaults shouldn't take a ton of extra work.

Per CJ though, that was never formalized into the framework.

geojeff commented 11 years ago

@mauritslamers has provided me with a starter gist for a LocalStorageDataSource, so maybe this will be the way to go.

dcporter commented 11 years ago

If it's public, would you mind linking it here? It's a great feature concept.

geojeff commented 11 years ago

https://gist.github.com/anonymous/5825758