Quantcast
Viewing all articles
Browse latest Browse all 4826

Best way to replace Mixins

@JonForest wrote:

We have a lot of existing code that makes heavy use of mixins - these provide 100s of actions and lifecycle hook functions for controllers, components and routes. Some of these mixins are many 100s of lines long, and some mixins include mixins.

I’d love to replace them as we move to a more Ember Octane view of the world, but I’m not sure what the best / canonical / recommended approach is?

In the past I’ve recommended moving everything into a service, importing into the the original route/controller/component and have the stub action/lifecycle hook immediately call the function on the service. It works because the explicitness of where the function is declared is obvious, but given the amount of places the mixins are used, and the size of them, this is still quite a lot of work and duplication.

We could inherit instead, but I’m not sure this makes for a much better world.

Or we could kick the can down the road given that classic Ember syntax is still supported for the foreseeable future. I actually expect that this will be part of any solution we adopt.

Suggestions welcome - thank you.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4826

Trending Articles