Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember mixin as interfaces

Tags:

ember.js

Can an Ember object use mupltiple mixins ? I think mixin is equivalent to interface in Java and in that case there should be provision to implement many mixin here -

App.Movie = Ember.Object.extend(App.FirstMixin, { .. });

If there is a SecondMixin as well , how can this object use that ?

like image 200
fortm Avatar asked Mar 22 '13 07:03

fortm


1 Answers

Yes, sure it can. Have a look at the code of the prominent ArrayController Class for instance:

Ember.ArrayController = Ember.ArrayProxy.extend(Ember.ControllerMixin,
  Ember.SortableMixin, {
  ....
});

And actually mixins can be used as an equivalent to Java interfaces, but a mixin is not limited to an interface definition. Mixins are a mean of multiple inheritance and can also provide properties and method implementations to the classes that are using them. So the notion of an interface is to limited for the mixin concept.

like image 136
mavilein Avatar answered Oct 20 '22 08:10

mavilein