Reputation: 1214
I'm developing a front-end app with Backbone. On the app start a service call where I get some user related data - numbers, currency, dateFormat and similar stuff. I have to save this data for future uses. the question is - where? It can be local storage - but its purpose is a bit different or some singleton Backbone Model. Are there better options?
Upvotes: 0
Views: 603
Reputation: 2856
Local storage is a useful tool for persisting data between user sessions. However you are suggesting that when the user first accesses the (single-page) application, a service call is made to retrieve user related data (something akin to a user profile I'd imagine, a profile pic, locale settings and user preferences).
This means there's no need to persist the data in the browser beyond any loaded javascript objects. The singleton model is a common pattern to tackle this.
For a good example on how to great a singleton Backbone model see this answer: https://stackoverflow.com/a/9825238/1084004
Upvotes: 1