PDA

View Full Version : Manage initial config of an object. Why to use double istructions?



American horizon
10 Jun 2016, 1:08 AM
Hi, i'm codin on a code of another person, and i encountered this istruction


Ext.define
(
"CS.view.Viewport",
{
extend:"Ext.container.Viewport",
constructor:function(o_config)
{
this.initialConfig = this.initialConfig || {};
o_config = o_config || {};

var o_myconfig =
{
layout: "border",

items:
[
{
region: "west",
xtype:"buttonsPanel",
width: 150,
height: 2000
},
{
region: "center",
xtype:"main-tabpanel"
}
]
};


Ext.apply(this.initialConfig, o_myconfig);
Ext.apply(this, this.initialConfig); //<----doubt there

this.callParent(arguments);
},

initComponent:function()
{
this.callParent(arguments);
console.log("Viewport initialized");
}
}
);


What i don't undestand is the reason of call

Ext.apply(this, this.initialConfig);
considering that i already applied it into the this.initialConfig in the previouvs istruction.

Jad
10 Jun 2016, 4:35 AM
Hy


in this instruction



Ext.apply(this.initialConfig, o_myconfig);


you apply o_myconfig to initialConfig