mardi 6 octobre 2015

Action bubbling in Ember

I am relatively new to Ember so forgive me if the answer to this question is obvious. I started a new job recently and I thought their approach to action bubbling was...curious.

This is a big application with a lot of deeply nested components. To bubble actions up to the controller, they have been using this sort of thing a lot:

actionName (parameter) {
    this.attrs.actionName(parameter);
},

This will then bubble one level up to the next component, where they will call the same action again. This will continue in such a way until it reaches the controller where the action is defined.

I am not a fan of this for various reasons, but mostly because it makes writing any new actions a chore.

My question is a two-parter:

1) For deeply nested components, is there a better solution?

2) I have seen sendAction before, but have not used it in practice. What is the difference between this.attrs.actionName(parameter);?

Thank you!

Aucun commentaire:

Enregistrer un commentaire