fortm
fortm

Reputation: 4198

Ember mixin as interfaces

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 ?

Upvotes: 10

Views: 2625

Answers (1)

mavilein
mavilein

Reputation: 11668

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.

Upvotes: 21

Related Questions