Forked from leocavalcante/gist:72de0e8460d3091bdd56
Last active
August 29, 2015 14:27
-
-
Save lolptdr/125276fcfc7ceea428bc to your computer and use it in GitHub Desktop.
ES6 Mixins
This file contains 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
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