Skip to content

0.3.0 Prototype

Ivan S Glazunov edited this page Feb 20, 2015 · 3 revisions

sources/prototype

Templates.Prototype

new T.Prototype() => this;

The main class for all classes.

Not intended for use immediately! Only inheritance!

Remove need for using new operator.

// Required use a new the first assembly.
var i0 = new Prototype();
var c0 = i0.extend();

// You can not use `new` from heir.
var i1 = c0(); // equal to `new c0();`

._parent

Prototype;

Set at inheritance in .extend.

Reference to prototype of this instance.

new Prototype().extend(function() {
    var parent = this._parent; // A parent at this particular inheritance.
    this.constructor = function() {
        this._parent; // Parent at the time of the call. Maybe any subsequent heir.
        parent.constructor.apply(this, arguments);
    };
});

._arguments

arguments;

Set at construction.

Always available arguments passed to the .constructor.

.returner

() => any;

Sets the behavior at the time of construction.

var c0 = new Prototype().extend(function() {
    var parent = this._parent; // A parent at this particular inheritance.
    this.returner = function() { return this; };
});
c0(); // => instanceof Prototype == true
var c1 = new Prototype().extend(function() {
    var parent = this._parent; // A parent at this particular inheritance.
    this.returner = function() { return 123; };
});
c1(); // => 123

.constructor

(...arguments: TArguments) => any;

Sets the behavior at the time of construction in TInjector.

var c = new Prototype().extend(function() {
    this.constructor = function(a, b, c) {
        this.temp = a+b+c;
    };
});
c(1, 2, 3).temp; // => 6

.extend

(...arguments: Array<TInjector|string>) => Function;

About TInjector.

var c0 = new Prototype().extend(function() {
    this.constructor = function(a, b, c) {
        this.temp = a+b+c;
    };
});
var i0 = c0(1, 2, 3);
i0.temp; // 6
var c1 = i0.extend(function() {
    this.constructor = function() {
        this.temp += this.temp;
    };
});
var i1 = c1();
i1.temp; // 12

Static methods.

var c0 = new Prototype().extend('temp', function() {
    this.temp = function() { return 123; };
});
c0.temp(); // 123

._static

() => void;

Is called when a successor constructor.

Allows you to create static options.

Clone this wiki locally