Skip to content
Buminta edited this page Nov 24, 2014 · 1 revision

Struct one class

module.exports = Class.extend({
    init: function(configs){
        this._super(configs);
    }
}).interface(OrtherClasses).implement(OrtherClasses);
Interface

Using somes class with method for class extend it need valid.

//animal.js
module.exports = Class.extend({
    methoddemo: function(){
        //nothing
    }
});

//person.js
var Animal = require('animal.js');
module.exports = Class.extend({
    methoddemo: function(){
        //somethings
        //In here need have 'methoddemo'
    }
}).interface(Animal);

U can using interface(ClassA, ClassB, ClassC);

Extend

Using somes class with method for class extend it need valid.

//animal.js
module.exports = Class.extend({
    runmethod: function(){
        //somethings
    }
});

//person.js
var Animal = require('animal.js');
module.exports = Animal.extend({
    demomethod: function(){
        this.runmethod();
        //somethings
        //In here had 'runmethod'
    }
});

Implements

All method from Class implemented will using for class here

module.exports = Class.extend({
    runmethod: function(){
        //somethings
    }
});

//person.js
var Animal = require('animal.js');
module.exports =Class.extend({
    demomethod: function(){
        this.runmethod();
        //somethings
        //In here had 'runmethod'
    }
}).implement(Animal);

U can using implement(ClassA, ClassB, ClassC);

Clone this wiki locally