Skip to content

Instantly share code, notes, and snippets.

@lolptdr
Forked from leocavalcante/gist:72de0e8460d3091bdd56
Last active August 29, 2015 14:27
Show Gist options
  • Save lolptdr/125276fcfc7ceea428bc to your computer and use it in GitHub Desktop.
Save lolptdr/125276fcfc7ceea428bc to your computer and use it in GitHub Desktop.
ES6 Mixins
var mixin = require('mixin');
class Cyclist {
ride() {
console.log(`${this.name} is riding`);
}
}
class Swimmer {
swim() {
console.log(`${this.name} is swimming`);
}
}
class Runner {
run() {
console.log(`${this.name} is running`);
}
}
class Triathlete extends
mixin(mixin(Cyclist, Swimmer), Runner) {
constructor(name) {
this.name = name;
}
letsDoIt() {
this.ride();
this.swim();
this.run();
}
}
let bob = new Triathlete('Bob');
bob.letsDoIt();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment