@xiwcx wrote:
Hi! I’m working on my first Ember addon and I needed a way to separate the attrs from the rest of the component object. I came across warnings against using
this.attrs
directly. What I came up with is:const getComponentAttrs = that => Object.keys(that.attrs) .reduce((attrs, attrName) => { attrs[attrName] = that[attrName]; return attrs; }, {});
invoked like so:
didUpdateAttrs() { this._super(...arguments); const attrs = getComponentAttrs(this); // and so on... },
Any thoughts on this approach? Is there a better or common method?
Posts: 1
Participants: 1