Skip to content

0.2.7 elements Prototype

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

Prototype

new () => this;

Main prototype.

  • Remove need for using new operator.
  • Required use a new the first assembly.

Instance

var Prototype = Templates.Prototype;

var instance = new Prototype();
var Extended = instance.extend();
var extInstance = /* new */ Extended();
// ...

._parent

Prototype;

Set at inheritance in .extend.

Reference to prototype of this instance.

  • Not intended for use immediately! Only inheritance!

._arguments

IArguments;

Set at construction.

Always available arguments passed to the .constructor.

.returner

() => any;

Sets that will be returned on construction.

.constructor

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

Sets the behavior at the time of construction.

It is recommended that the first line to call the parent constructor.

div()().extend(function() {
	var parent = this._parent;
	this.constructor = function() {
		parent.constructor.apply(this, arguments);
	};
});

What is the difference between ._parent and the parent argument in the .extend method? ._parent refers to the last parent. .extend parent argument refers to the last parent to a specific TInjector.

.extend

(injector?: TInjector) => Function;

var injector = function(parent) {
	var parent = this._parent;
	this.constructor = function() {
		parent.constructor.apply(this, arguments);
	};
};
div()().extend(injector);
TInjector

() => void;

Clone this wiki locally