We use Ember at my work and I’ve noticed a new trend on code reviews from other developers that all default values need to be set in the init hook with setProperties instead of just setting the property directly on the component. This seems like it is unneccessary and adds more code lines vs just adding val:default_value to a component. I can’t find any evidence that properties should be set in init. I’m pretty sure this only applies to mixins and reference based values like arrays. So, are there any benifits to setting component property default values in the init hook vs just straight on the component?
Component.extend({
prop: 'default_value'
});
vs
Component.extend({
init(){
this._super(...arguments);
this.setProperties({
prop: 'default_value'
});
}
});