Best way to replace Mixins

Follow-up on this write-up on removing mixins: I stand by it, but I would now add one further option to the mix, which should go at the very top of the list: many mixins are best replaced by modifiers. Many (perhaps a majority) of the mixins I have encountered over the last six months are primarily a way of reusing common interactions with the DOM.

While in Ember Classic a better abstraction for this was often using contextual (or “higher-order”) components, that had other downsides which meant teams often just reached for a mixin instead. In Octane, modifiers neatly solve that problem, with better reusability and composability, so add that to your toolkit, and as quickly as possible!

2 Likes