View Full Version : Stores without model, lists without stores discussion

28 Nov 2011, 8:16 AM
My app is basically a viewer for live data from the server in json format. I have some forms that allow me to update the server and all the data needs to be current and dynamic. There is no offline storage of data however I may need to retain the data between card switch (so that it doesn't load new data on every card switch - perhaps on initial one and then with a refresh button - still figuring out how to keep data fresh without polling)

My question is.. I see that I can use stores without models (as per twitter example in dataview docs). So what would be the benefit of using models? I plan on submitting my forms straight to sever for validation so I don't really have a need to use local validation.

Also - it seems that belongsTo associations do not work and frankly I don't think the association concept in ST will be useful for my needs so I am questioning using stores instead of just pulling json data into a list. What would be the pros and cons? It seems easy enough to load json data into a template - would I have issues with list views and disclosures?

As far as my views on associations - I'd also like to hear your inputs. Let's say that I pull messages with related user data - but I only pull some of the user data (i.e ID, name). Since it's broken I don't know what normally happens but would the user data be theoretically stored in the user store? And since its incomplete (id and name only) - what happens when I request that user? will I get an error when I want to print out their email for example since it's not been pulled? And if the store pulls a refreshed user from live sever then what is the point of the association in the first place?

Get my drift? :) I'd love some thoughts towards the matter


28 Nov 2011, 8:43 AM
Basically you want to know what are the pros and cons of the data package huh?

Associations... if you don't need them then don't use them. It can be an easy way to get a parent Model or children Models and they work... just have somethings that you have to watch for.

Models... If you don't specify a Model in a Store, the Store will create a Model based on the fields Array you specified in your Store. I would always build Models as it's a layer of organization and if you ever want to use validations or associations, the Model is already there.

Associations and Views... using the getter method for the belongsTo, it returns a single Model instance that you can use for anything... my favorite is to load data from it onto forms. hasMany getter will return a Store and you can use it for lots of things... most notable is a List.

28 Nov 2011, 9:27 AM
Thanks for your reply. However associations for belongsto do not work - I have 2 posts pending on this with no solutions (one solution in ST1 was to override fetchAssociatedData - or something like that - can't remember offhand) and was told by you that I could no longer override it. But it's not possible to fetch a a store and parse the belongsto association in the template - if it was it would be more straightforward for me - but this is why I am now questioning my approach.

If I had no need for validation or associations then should I consider parsing stright json data into a list instead of through a store or would I lose some additional functionality?