What is the difference between mixins and plugins and when should you use them? I've seen a few posts online but I want to hear your opinions on it.

evant

6 Aug 2012, 4:21 PM

A mixin adds extra functionality to the class directly. So, for example, when the Observable mixin is used, it adds on/un/etc to the class so you can call them directly.

A plugin is more of a "call out" functionality, the component asks the plugins to initialize and then the plugins (usually) listen to events on that component and reacting., instead of directly adding any functionality.

dirtdevil

7 Aug 2012, 11:31 AM

If mixins add extra functionality to the class directly, wouldn't it be better to use mixins instead of plugins? I'm sure due to the nature of plugins being some kind of external entity you would run into issues because of that.

mankz

7 Aug 2012, 1:23 PM

A mixin augments a class while a plugin augments an instance of a class.