Skip to content

Commit

Permalink
Add a helper function to generate decorators for mixin inclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Dec 6, 2015
1 parent dc75810 commit d2ed759
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/mixins/include.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use babel'

/**
* Generates a decorator function to includes many `mixto` mixins into a class.
*
* @param {...Mixin} mixins the mixins to include in the class
* @return {function(cls:Function):Function} the decorator function that will
* include the specified mixins
* @example
* @include(SomeMixin)
* export default class SomeClass {
* // ...
* }
*/
export default function include (...mixins) {
return function performInclusion (cls) {
mixins.forEach((mixin) => { mixin.includeInto(cls) })
return cls
}
}

0 comments on commit d2ed759

Please sign in to comment.