0.1.7 • Published 12 years ago

inherit.js v0.1.7

Weekly downloads
43
License
-
Repository
github
Last release
12 years ago

inherit.js - Inheritance javascript library

inherit.js is an inheritance javascript library, which supports base method calls an easy way along the inheritance path.

Usage

Declare a class

var YourClass = inherit.Base.inherit({
    ctor: function(foo, bar) {
        // constructor
        this.foo = foo;
        this.bar = bar;
    },
    publicFunction: function() {
        // function declaration
    }
});

Inherit from your class

var DerivedClass = YourClass.inherit({
    ctor: function(foo, bar) {
        // call base ctor
        this.base.ctor.call(this, foo, bar);
    },
    anotherPublicFunction: function(){
        // your code goes here
    },
    // overwrite method
    publicFunction: function() {
        // call base method
        this.base.publicFunction.callBase(this);

        // do other stuff
    }
});

Create instances

var foo = new YourClass("foo", "bar");
var bar = new DerivedClass("bar", "foo");
0.1.7

12 years ago

0.1.6

12 years ago

0.1.5

12 years ago

0.1.4

12 years ago

0.1.3

12 years ago

0.1.2

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago