Friday, March 22, 2013

Mixins in Ext JS 4 - On why mixins are useful

Mixins are really useful when a class needs to inherit multiple traits but can’t do so easily using a traditional single inheritance mechanism. For example, Ext.Windows is a draggable component, as are Sliders, Grid headers, and many other UI elements. Because this behavior crops up in many different places it’s not feasible to work the draggable behavior into a single superclass because not all of those UI elements actually share a common superclass. Creating a Draggable mixin solves this problem – now anything can be made draggable with a couple of lines of code.
http://edspencer.net/2011/01/classes-in-ext-js-4-under-the-hood.html

No comments:

Post a Comment