First of all, I'm still learning EmberJS. :)
I had the same problem: how to add generic classes to a class.
I understand that you cannot do this with Mixins ( Warning : I may be wrong), but you can do this using a simple subclass.
Take a look at jsbin . App.Soldier is a subclass of App.Person that contains instance and class methods. They are available for App.Soldier.
If you type these commands in the console:
x = App.Soldier.create(); x.hello(); // => "hello world!" x.fire(); // => "Laser gun, pew! pew!" App.Soldier.identifyYourself(); // => "I'm a humanoid carbon unit"
The disadvantages of this approach are that someone is free to instantiate an App.Person object. In addition, you cannot subclass multiple parent classes.
Anyway, I hope this helps
David
source share