I am new to ember.js and looking to create several reusable components that can be used across various independent but related applications.
Unlike many of the examples I have seen, these components that I want to re-use are not purely UI related. I’d like them to load most of their data by themselves. The data loaded can be tweaked by supplying some options to the component.
This seems like a good idea because:
- Users of the components can easily drop them into their templates.
- Users of the components only have to supply minimal configuration options. They do not have to get the data/model for the component.
At the same time this seems strange to me when looking at examples of simple Ember.js applications such as the TODO app. In these applications:
- A route is responsible for loading the model.
- Templates are able to access that data via the controller.
Is it appropriate for Ember Components to do things like loading data? What problems would this cause? Is there another design pattern that would allow me to easily share these complex components across multiple applications without loading the data from the component itself?