Let's assume I have defined several new components -MyComponent1
, MyComponent2
, ..., which extend Ext.Component
.
Now I wnat to extend all this widgets with the same functionality - I want to add close
button which would appear at the top-right position of MyComponentX.el
.
What should I use: mixin
? plugin
? or something else?
And in general: mixin vs plugin
, what is the best practise?
I like to think about it as -
mixin
is what you use to achieve 'multiple inheritence'
plugin
is what you use to enhance an existing component. plugin's lifecycle is managed by the component. (no lifecycle managemen for mixin. think of mixin as base class equivalent)
Mixin properties and functions are injected into the class directly so they are part of the class definition.
plugins are added at the instance level
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With