Extendable Mixins

I’m finding myself building more and more mixins the more I use ember. A problem I’m finding though, is I often am writing code that feels like a reusable mixin that’d be awesome to extend on multiple mixins. I have some functionality that I’d like to extend out of two mixins and put in another mixin, but it doesn’t really seem possible. I found I could partially cheat and reopen the class, but that isn’t really working how I wanted it to.

I really want to do

Ember.Mixin.create(someOtherMixin, someOtherMixin2{ yadda yadda yadda});

or even

Ember.Mixin.extend(someOtherMixin, someOtherMixin2{ yadda yadda yadda});

How have other people generated reusable code that’s shareable across multiple portions of your ember app?

This actually works:

Ember.Mixin.create(App.OtherMixin, {...})

See this example: http://jsbin.com/akefoz/1/edit

2 Likes

Well hell, I swore I tried that. I feel sheepish.

To feel a little better about myself, I realize it was actually the order my js files were being sent down. they were being initialized in the wrong order and dying.

See your same example broken http://jsbin.com/akefoz/6/edit