2

I'm using Boilerplatejs to structure a web application where I have "forums" and "categories". On the categories module, I have components that list all categories and edit a specific category (just like the list-detail example bundled with boilerplatejs).

When registering a new forum, I need to list all the categories, which are retrieved using Ajax on a tag on the module initialization, so, if I add a new category using the categories module, that list won't be updated when I add a new forum.

Following the BoilerplateJS guidelines, I could emit an event when the categories list is updated, so other modules could trigger a new ajax request and fetch the updated categories list, but would it be sane to have a shared datasource (or component) which would minimize the network requests ?

Hasith
  • 1,749
  • 20
  • 26
guigouz
  • 1,211
  • 1
  • 13
  • 18
  • 1
    what if you pass the 'categories list' with your event? So that other components do not need to go to the server to fetch the new category list? – Hasith Oct 30 '12 at 02:58
  • nice workaround, will implement it this way, but I still think shared components may be useful, for example, you could have a module which depends on the "users" module components to add/edit users on a popup. – guigouz Oct 31 '12 at 13:53
  • 1
    I do not disagree the fact it is useful to have shared state... but my approach is to make the client stateless as much as possible. I do not generally keep buffers/temp storage on clients since it tend to create inconsistencies specially in multi-user scenarios. It is a best practice to keep the server as the 'single truth of application state' where ever possible. – Hasith Nov 01 '12 at 02:24

0 Answers0