Cereal Killer
Cereal Killer

Reputation: 3414

Ember, extending multiple classes

Is it possible in Ember to extend multiple classes? For example:

 App.View1 = Ember.View.extend({ .. });

 App.View2 = Ember.View.extend({ .. });

 App.View3 = //here you want to extend View1 and View2 but without making View2 extending View1 or viceversa...

Upvotes: 2

Views: 2450

Answers (1)

poweratom
poweratom

Reputation: 2434

No, you can not extend or inherit from multiple classes. Ember only allows for single class inheritance. You are, instead, encouraged to use Mixins to "compose" your classes. In reality, using Mixins would probably make your application more modular to design and extend. And they are super easy to use in Ember.

You can find references here: http://emberjs.com/api/classes/Ember.Mixin.html

Jeffrey Biles also did a short & sweet screencast on this topic.

There's also a "pro" screencast he did on Mixins should you be interested.

Upvotes: 2

Related Questions