Two articles that describe binary-based Mixin and Trait-based approaches for JavaScript include A New Look at JavaScript Mixins by Angus Croll in May 2011 and Many JavaScript Talents to Summarize Platform-Oriented Approaches, such as Features and Mixes since April 2014.
so long
Appendix I
see also:
- stackoverflow.com :: Features in javascript
- stackoverflow.com :: How to properly use mixins in Javascript
Appendix II
Since from time to time I seem to play with this question, I do not want to add any last thoughts to it ...
The libraryβs agnostic approach without much glue code (as mentioned above) only works for very fine-grained behavioral reuse units. Thus, until one gets into more than 1 or 2 easily resolved conflicts, templates based on, for example, Angus Croll Flight Mixins are the way to the next.
If it comes to real features, there must be a level of abstraction for him. This level (for example, provided as some kind of syntactic sugar such as DSL) should hide complexity, for example. compiling signs from signs or resolving conflicts when setting time (when the behavior of an object is tied to an object / type).
There are currently 3 examples in SO that, from my point of view, provide exactly what the OP requested ...
Any examples in the real world are also welcome.
- stackoverflow.com :: Composts and Mixers in JS
- stackoverflow.com :: Mixers for ES6 classes overflowing with babel
- stackoverflow.com :: Refactoring legacy mixing hierarchies
- stackoverflow.com :: Multiple Inheritance Using Classes
Peter Seliger May 20 '14 at 20:31 2014-05-20 20:31
source share