This is simple and is a great way to do mixins in a ruby-module-style. However, we're using this in a few recipes where "real inheritance" would be more appropriate than a mixin:
Views.X = Backbone.View.extend({{
foo: function() { }
});
// Then the view just extends the other view
Views.Y = Views.X.extend({
bar: function() { }
});
The difference here is mixin vs inheritance. I think for the most part we're using mixins right in our recipes, but there may be a few cases for inheritance.
We're using _.extend's ability to accept additional mixin classes for exension:
This is simple and is a great way to do mixins in a ruby-module-style. However, we're using this in a few recipes where "real inheritance" would be more appropriate than a mixin:
The difference here is mixin vs inheritance. I think for the most part we're using mixins right in our recipes, but there may be a few cases for inheritance.
This is taking advantage of a special behavior of Backbone's extend (which is different from _.extend) and is self-propagating: http://documentcloud.github.com/backbone/#Model-extend