mardi 5 juillet 2016

Multiple component with multiple models

So, I'm building an EmberJS application and I have a route, containing multiple components (e.g. messages and questions).

Each component is extended with a dyn-widget mixin that allows it to be dragged by the user across the screen, as they are presented to the user as windows on a canvas.

To store the information about each dyn-widget window, I use three Ember Data models: a dyn-widget that stores values shared by any widget (position, size...), and a dyn-widget/questions and a dyn-widget/chat that contain additional information about how the widget is set up and a one-to-one relationship to the 'parent' dyn-widget model.

The route has a corresponding controller that allows the user to instianciate new windows. The controller then creates a dyn-widget/whatever model along with the associated dyn-widget model, and everything is stored in the local storage.

However, when I try to implement the model() function into the route, I've found that I can't really return multiple, different models without hacky solutions. I thought of putting the models directly into my components but that breaks the following pattern:

Components are isolated entities that consume data through their
interface, react to data changes that flow via data binding, and 
possibly send up named actions.

So how should I approach this? What would the a non-hacky, Ember way to this issue?

Thanks!




Aucun commentaire:

Enregistrer un commentaire