mardi 25 avril 2017

Ember.js Best Practices - Can/Should I override sendAction?

In my Ember App, I have a large number of modal dialog components that I render in my Application route like so:



All dialog components extend from a single base class, where, for convenience, I have overridden sendAction. The point of the override is to always trigger some action on the target, as opposed to sendAction's default behavior of "if the property is undefined, do nothing". Here is what that looks like:

sendAction: function (actionName) {
  if (Em.isEmpty(this.get(actionName))) {
    this.set(actionName, actionName);
  }
  this._super(...arguments);
},

This seems to work as I would expect: always triggering an action on the target that will then bubble up the stack. What I'm wondering is...

Are there any implications/side-effects of overriding sendAction that I am not aware of?




Aucun commentaire:

Enregistrer un commentaire