Skip to content

Instantly share code, notes, and snippets.

@developit
Created September 21, 2015 12:30
Show Gist options
  • Save developit/561880458cfb6ea731ce to your computer and use it in GitHub Desktop.
Save developit/561880458cfb6ea731ce to your computer and use it in GitHub Desktop.
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