It really depends on the context. Some data you might want to pre-load once and be done with it. This is usually good for more static data or app configuration. Most data you need to load on-demand. An example from my job-tracking app I'm currently working on: based on the logged in user, I grab all their job tickets just for that user. This Ajax request provides a summary view of the job number, customer, and description. If they want more detailed information for a job, then I do another Ajax request to get all the details for just that job. As an example of data that just loads on init - there is a list of about 2000 materials that can be consumed for a job, and those need to be tracked along with the time. For the material list, I grab it once since it rarely changes. As an optimization, I don't even grab it each time - I cache the material list in local storage and then when the app starts I make a quick call to another service that tells me if the material list has changed, and only then do I fetch it again. That's just an example of how to start to this about state for SPAs. If you want to give more details on your app, I can make some specific suggestions, but it's hard to talk about in the abstract.
If you're used to rendering web pages on the server, the React model is a very natural fit. On the server, you would generally query the db, maybe look up or store some things in the session, and then render your templates. With react, the query is replaced by an Ajax call, the local state replaces the session, and the React components replace your templates. It's not a perfect analogy, but pretty close and you can start thinking in those terms and then optimize as needed (for example, by caching additional server data locally, just as you might cache data in the session or Redis to optimize a server-based web app) -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
