JJR
JJR

Reputation: 773

Ext.apply cover nested objects?

I have some configuration objects that I need to copy into another. I don't care about cloning the reference but there a deep nested objects within the configuration which need to get merged to. The problem is I do not know which of these configurations exist or how deep they are currently nested. Ext.apply is called in a loop and first test show that it seems to override the property of the previous loop.

Can I make Ext.apply to run apply on child objects too?

Upvotes: 2

Views: 1323

Answers (1)

sra
sra

Reputation: 23973

Look at the API for Ext.apply and you will find the answer in the method description

Copies all the properties of config to the specified object. Note that if recursive merging and cloning without referencing the original objects / arrays is needed, use Ext.Object.merge instead.

I think Ext.Object.merge will do what you need

Merges any number of objects recursively without referencing them or their children.

Upvotes: 4

Related Questions