HubSpot / mixen

Combine Javascript classes on the fly
http://github.hubspot.com/mixen
MIT License
85 stars 2 forks source link

Document its use for React.js v0.13 and up #10

Open wmertens opened 9 years ago

wmertens commented 9 years ago

If I understand this correctly, this means you can replicate the mixins mechanism so that you can use plain classes for React.js ≥0.13 as described at https://github.com/facebook/react/blob/master/docs/_posts/2015-01-27-react-v0.13.0-beta-1.md#mixins

So it would be nice to mention this in the readme :grin:.

timmfin commented 9 years ago

In theory yes, but in practice not quite. This implementation relies on how CoffeeScript adds __super__ to classes. And with that, you often need to do some gymnastics to ensure that all of your mixins call super in the right places to ensure that all other mixins (and super classes) are called.

So IMHO, this could help you mimic React mixins in a some simple cases. But as soon as you start using external mixins (not authored by you) or introduce multiple levels of inheritance, things get very tricky/fragile very fast (not to mention hard to debug)

wmertens commented 9 years ago

@timmfin Hmmm, maybe non-native mixins could be wrapped with a helper class? CS classes have a Classname.super attribute.