lundi 25 janvier 2016

How to nest components in a proper way

I'm starting with EMBER.js, and there are some doubts that I have:

Let's say that I am creating a simple chat, just for the example. I have a left-side panel with a list of users, and a right-side panel with the messages sent.

I considered creating a component called: users-list, that displays a list of users. Every member of that list should be another component called user.

This means that a user component is responsible of drawing itself, with the user name, last sent message, name color, etc... (all are properties) and also has some actions in buttons beside its name: changeName, changeColor, leaveRoom.

While a users-list is responsible for maintaining a list of users and displaying them using the user component.

So the questions here are:

  1. Is this the proper way to go?
  2. If it is: How can I delete an item from the users-list component, from an action inside of the child user component (leaveRoom action)?
  3. If not: How should I implement that? I'd like to keep responsibilities isolated.



Aucun commentaire:

Enregistrer un commentaire