es6-class-mixin
v1.0.5
Published
Tiny tool to add mixins for ES6 classes.
Downloads
529
Maintainers
Readme
Mixin for ES6 classes
Mixins for ES6 Classes. Based on @mattmccray's gist
Install
npm i -S es6-class-mixin
API
mixin
extends given class by object with functions or properties.
mixin(ParentClass, ...mixins) // return new MixedClass extended by Mixins
Examples
// Basic
const mixin = require('es6-class-mixin');
class ListItem {};
let draggable = {
drag() { /* … */ }
};
let droppable = {
drop() { /* … */ }
};
class DraggableItem extends mixin(ListItem, draggable, droppable) {}
// Backbone
class Input extends mixin(Backbone.View, Dispatcher.mixin) {}
License
MIT