Skip to content

lenville/es6-classes-mixin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ES6-Classes-Mixin

You can use function mix to extend your classes like this:

class NewClass extends mix(classA, classB [, classC, ...]){
  constructor(...args) {
    super(...args)

    // Your code here
  }
}

This function will automatically mix all your class in together and manage every Constructor for you. In other words, you're able to set your superclass as the first class.

class NewClass extends mix(superclass, classA, [, classB, ...]){
  constructor(...args) {
    super(...args)

    // Your code here
  }
}

If you don't like this kind of mixin function, please check MixWith.js for more infomation.

Define a Mixin:

let MyMixin = (superclass) => class extends superclass {
  // mixin methods here
};

Use a Mixin without mixwith:

class MyClass extends MyMixin(MySuperClass) {
  // class methods here, go ahead, use super!
}

Use a Mixin with mixwith:

class MyClass extends mix(MySuperClass).with(MyMixin, OtherMixin) {
  // class methods here, go ahead, use super!
}

About

ES6 Class Mixin supported IE 9+

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published