Sharing datasources between components on a Boiler

2019-07-20 09:00发布

问题:

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 ?