Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nsisodiya/es6-mixins

ES6 Mixins, Useful for adding Mixin support to React Component when you use ES6 class syntax
https://github.com/nsisodiya/es6-mixins

Last synced: about 1 month ago
JSON representation

ES6 Mixins, Useful for adding Mixin support to React Component when you use ES6 class syntax

Awesome Lists containing this project

README

        

# es6-mixins
ES6 Mixins, Useful for adding Mixin support to React Component when you use ES6 class syntax

# Installation

```
npm install --save @nsisodiya/es6-mixins
```

# Usage

```js
import Mixin from '@nsisodiya/es6-mixins';

// The first class to be used as a mixin
class TestMixin1 {
testMethod1() {
console.log('test Method 1 from TestMixin1');
}

testMethod2() {
console.log('test Method 2 from TestMixin2');
}
}

// The second class to be used as a mixin
class TestMixin2 {
testMethod1() {
console.log('test Method 1 from TestMixin2');
}
}

class MainClass {
constructor() {
this.testMethod1(); // outputs 'test Method 1 from TestMixin2' and then 'test Method 1 from TestMixin1' will warn in console about duplicate methods.
}
}

Mixin(MainClass, [TestMixin1, TestMixin2]);

new MainClass();
```