Skip to content

0.2.2 e Prototype

Ivan S Glazunov edited this page Feb 20, 2015 · 4 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.

.return

() => 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(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) {
	this.constructor = function() {
		parent.constructor.apply(this, arguments);
	};
};
div()().extend(injector);
TInjector

(parent: Prototype) => void;

Clone this wiki locally