Created
September 21, 2015 12:30
-
-
Save developit/561880458cfb6ea731ce 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
let behaviorA = { | |
greet(greeting) { | |
return greeting; | |
} | |
}; | |
@mixes(behaviorA) | |
class Foo { | |
test() { | |
return this.greet('hi from Foo'); | |
} | |
} | |
console.log( new Foo().test() ); | |
// mix behaviors into a class. | |
function mixes(...behaviors) { | |
return target => behaviors.forEach( b => Object.assign(target.prototype, b)); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment