25 Sep 2012 2:34 AM #1
Sencha 2 "child store" or "sub store"
Just had a revelation when it comes to data stores inside Sencha Touch.
I was treating stores as a central repository of data I've loaded from the server, and used those same stores to populate my lists and data views. I was doing this because I was under the impression that I was saving memory and resources.
Problem was - I was seeing a lot of my views slow down, because I had to filter each store on show of the view. Another problem I was running into was looking up items in the store when I had filters applied. This was quickly becoming messy.
It took me awhile, but I realized that I should have stores for each view component, and simply populate them with data I'm keeping in "central stores". The stores for each view can then be filtered & sorted without causing item lookup issues or performance problems.
Taking a page from SQL I came up with the idea of a "ChildView" store to use for my lists and other data views. Set a parentStore on the ChildView, then you can filter away at the ChildVIew without effecting your central data.
You can even set a "queryFunc" to restrict the type of data that gets pulled from your parentStore. This data is kept in sync by watching the events on parentStore, and reloading it as items change.
Would love to hear feedback on this, and hopefully it helps someone having the same problems I was.
25 Sep 2012 9:56 AM #2
Interesting work! I am struggling with similar issues in my app, and I have two questions for you:
- How does your solution compare to https://market.sencha.com/users/24/extensions/52 ?
- If a record is present in multiple stores, does a record update reflect in all stores?
25 Sep 2012 12:56 PM #3
If a record is present in multiple stores, does a record update reflect in all stores?
#2 is important because your code seems to ensure that record updates in the parentStore propagate to the childStore, but the reverse scenario doesn't seem to be supported.