setup
can.Construct.setup
Perform initialization logic for a constructor function.
can.Construct.setup(base, fullName, staticProps, protoProps)
A static setup
method provides inheritable setup functionality
for a Constructor function. The following example
creates a Group constructor function. Any constructor
functions that inherit from Group will be added to
Group.childGroups
.
Group = can.Construct.extend({
setup: function(Construct, fullName, staticProps, protoProps){
this.childGroups = [];
if(Construct !== can.Construct){
this.childGroups(Construct)
}
Construct.setup.apply(this, arguments)
}
},{})
var Flock = Group.extend(...)
Group.childGroups[0] //-> Flock
Parameters
-
base
{constructor}
The base constructor that is being inherited from.
-
fullName
{String}
The name of the new constructor.
-
staticProps
{Object}
The static properties of the new constructor.
-
protoProps
{Object}
The prototype properties of the new constructor.
The static
setup
method is called immediately after a constructor function is created and set to inherit from its base constructor. It is useful for setting up additional inheritance work. Do not confuse this with the prototypesetup
method.Setup Extends Defaults
Setup deeply extends the static
defaults
property of the base constructor with properties of the inheriting constructor. For example:Example
This
Parent
class adds a reference to its base class to itself, and so do all the classes that inherit from it.