I would like to include standard functionality in several views in an Ember application. Functionality includes such things as setting the tagName and classNames in the views the same and tracking properties for each view.
Question in a nutshell: should you use mixing or expand the base view?
Extended question ...
Is it possible to expand the base view to do this? For instance:
App.BaseView = Em.View.extend({ tagName: 'section', classNames: ['page_section', 'blue'], willInsertElement: function() {
... Or should you use Mixin to extend functionality? For instance:
App.BaseMixin = Em.Mixin.create({ tagName: 'section', classNames: ['page_section', 'blue'], willInsertElement: function() {
I understand that views and mixins are both Ember objects, but whether they use either of them to extend standard functions to other objects (e.g., views) affects the way objects and prototypes / instances interact (if they differ from the object) , and properties are set in the instance of the view or view object?
If the two examples above are different, will the properties in the mixin initialization function change anything? For instance:
App.BaseMixin = Em.Mixin.create({ tagName: null, classNames: null, init: function() { this.set('tagName', 'section');
However, if the use of mixin and the extension of the view have the same effect on the views to which I am trying to add standard functionality (that is, they equally affect the view objects and prototypes / instances), do you see the advantage of using one over the other (whether with point of view of efficiency, maintainability, etc.)?