wwl-js-mixin-chain
v0.1.0
Published
| Master | Develop | |--------|---------| | [](https://travis-ci.org/wonderweblabs/wwl-js-mixin-chain) | [ -> class MA extends superclass
attribute1: 10
attribute3: 30
getValue1: -> super() + 10
getValue4: -> 'MixinA'
@getStaticValue1: -> super() + 10
@getStaticValue4: -> 'MixinA'
MixinB = (superclass) -> class MB extends superclass
attribute2: 200
attribute3: 300
getValue1: -> super() + 100
getValue2: -> super() + 100
getValue4: -> 'MixinB'
@getStaticValue1: -> super() + 100
@getStaticValue2: -> super() + 100
@getStaticValue4: -> 'MixinB'
Inherit SuperClass only
ext = require('wwl-js-mixin-chain')
class T extends ext(SuperClass).with()
t = new T()
t.attribute1 # 1
t.attribute2 # 2
t.attribute3 # 3
t.getValue1() # 1
t.getValue2() # 2
t.getValue3() # 3
t.getValue4() # 4
T.getStaticValue1() # 1
T.getStaticValue2() # 2
T.getStaticValue3() # 3
T.getStaticValue4() # 4Inherit SuperClass with MixinA
ext = require('wwl-js-mixin-chain')
class T extends ext(SuperClass).with(MixinA)
t = new T()
t.attribute1 # 10
t.attribute2 # 2
t.attribute3 # 30
t.getValue1() # 11
t.getValue2() # 2
t.getValue3() # 3
t.getValue4() # 'MixinA'
T.getStaticValue1() # 11
T.getStaticValue2() # 2
T.getStaticValue3() # 3
T.getStaticValue4() # 'MixinA'Inherit SuperClass with MixinB
ext = require('wwl-js-mixin-chain')
class T extends ext(SuperClass).with(MixinB)
t = new T()
t.attribute1 # 1
t.attribute2 # 200
t.attribute3 # 300
t.getValue1() # 101
t.getValue2() # 102
t.getValue3() # 3
t.getValue4() # 'MixinB'
T.getStaticValue1() # 101
T.getStaticValue2() # 102
T.getStaticValue3() # 3
T.getStaticValue4() # 'MixinB'Inherit SuperClass with MixinA and MixinB
ext = require('wwl-js-mixin-chain')
class T extends ext(SuperClass).with(MixinA, MixinB)
t = new T()
t.attribute1 # 10
t.attribute2 # 200
t.attribute3 # 300
t.getValue1() # 111
t.getValue2() # 102
t.getValue3() # 3
t.getValue4() # 'MixinB'
T.getStaticValue1() # 111
T.getStaticValue2() # 102
T.getStaticValue3() # 3
T.getStaticValue4() # 'MixinB'Inherit SuperClass with MixinB and MixinA
ext = require('wwl-js-mixin-chain')
class T extends ext(SuperClass).with(MixinB, MixinA)
t = new T()
t.attribute1 # 10
t.attribute2 # 200
t.attribute3 # 30
t.getValue1() # 111
t.getValue2() # 102
t.getValue3() # 3
t.getValue4() # 'MixinA'
T.getStaticValue1() # 111
T.getStaticValue2() # 102
T.getStaticValue3() # 3
T.getStaticValue4() # 'MixinA'