WWL JS Mixin Chain
Master | Develop |
---|---|
The mixin chain allows to include prototypes with an undefined parent class into your classes structure.
So you can append prototypes with mixin like code by using the ext
function of the mixin chain.
Mixin prototypes needs to be encapsuled inside a function getting the super class as parameter.
Example
Let's assume, we've got the following super class:
attribute1: 1 attribute2: 2 attribute3: 3 : -> 1 : -> 2 : -> 3 : -> 4 : -> 1 : -> 2 : -> 3 : -> 4
And then, we implemented the following mixins which are overwriting some attributes, instance functions and class functions:
= attribute1: 10 attribute3: 30 : -> super + 10 : -> 'MixinA' : -> super + 10 : -> 'MixinA' = attribute2: 200 attribute3: 300 : -> super + 100 : -> super + 100 : -> 'MixinB' : -> super + 100 : -> super + 100 : -> 'MixinB'
SuperClass
only
Inherit ext = require'wwl-js-mixin-chain' SuperClasswitht = tattribute1 # 1 tattribute2 # 2 tattribute3 # 3 tgetValue1 # 1 tgetValue2 # 2 tgetValue3 # 3 tgetValue4 # 4 TgetStaticValue1 # 1 TgetStaticValue2 # 2 TgetStaticValue3 # 3 TgetStaticValue4 # 4
SuperClass
with MixinA
Inherit ext = require'wwl-js-mixin-chain' SuperClasswithMixinAt = tattribute1 # 10 tattribute2 # 2 tattribute3 # 30 tgetValue1 # 11 tgetValue2 # 2 tgetValue3 # 3 tgetValue4 # 'MixinA' TgetStaticValue1 # 11 TgetStaticValue2 # 2 TgetStaticValue3 # 3 TgetStaticValue4 # 'MixinA'
SuperClass
with MixinB
Inherit ext = require'wwl-js-mixin-chain' SuperClasswithMixinBt = tattribute1 # 1 tattribute2 # 200 tattribute3 # 300 tgetValue1 # 101 tgetValue2 # 102 tgetValue3 # 3 tgetValue4 # 'MixinB' TgetStaticValue1 # 101 TgetStaticValue2 # 102 TgetStaticValue3 # 3 TgetStaticValue4 # 'MixinB'
SuperClass
with MixinA
and MixinB
Inherit ext = require'wwl-js-mixin-chain' SuperClasswithMixinAMixinBt = tattribute1 # 10 tattribute2 # 200 tattribute3 # 300 tgetValue1 # 111 tgetValue2 # 102 tgetValue3 # 3 tgetValue4 # 'MixinB' TgetStaticValue1 # 111 TgetStaticValue2 # 102 TgetStaticValue3 # 3 TgetStaticValue4 # 'MixinB'
SuperClass
with MixinB
and MixinA
Inherit ext = require'wwl-js-mixin-chain' SuperClasswithMixinBMixinAt = tattribute1 # 10 tattribute2 # 200 tattribute3 # 30 tgetValue1 # 111 tgetValue2 # 102 tgetValue3 # 3 tgetValue4 # 'MixinA' TgetStaticValue1 # 111 TgetStaticValue2 # 102 TgetStaticValue3 # 3 TgetStaticValue4 # 'MixinA'