Created
August 29, 2013 01:45
-
-
Save zackbloom/6373430 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mixins = {} | |
| registerMixin = (name, mixin) -> mixins[name] = mixin | |
| defaultMixins = ['event-janitor'] | |
| registerMixin 'event-janitor', EventJanitor | |
| registerMixin 'remember-me', RememberMe | |
| MixMaster = (mixins...) -> | |
| out = _.clone defaultMixins | |
| for mixin in mixins | |
| if mixin[0] is '+' | |
| out = _.union out, mixin.substring(1) | |
| else | |
| out = _.without out, mixin.substring(1) | |
| Mixen out | |
| # You can now make classes like this: | |
| class MyView extends MixMaster('+remember-me', '-event-janitor') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment