How to clone getSettings?

Tags: #<Tag:0x00007f0b00367010>

Hi,

I’m trying to get my HandsOnTable’s settings with the getSettings method.
And that’s working.
What I need is to update this object (returned by the method) before sending it to my server.
But if I update the object, It will update my GUI (because it’s a reference). That’s not what I need.
So I duplicated the object with {...myObj}.
But I don’t know why, the duplicated object is empty :confused:

Can you please tell me why ? (JSFiddle)

Have a nice day,
HeyHeyChicken

Welcome my HeyHeyChicken friend!

I will investigate this case and come back to you shortly.

1 Like

I’m already back.

We’ve made a quick brainsorm and ended up with this demo https://jsfiddle.net/2naxdfuq/

The first attempt did not work as GridSettings are getting the settings from their prototype.

ps. or if you just operate on JSONs

JSON.stringify(Object.getPrototypeOf(hot.getSettings()))

We used the deepClone (JSON method).

ps2. Can you tell me what are you doing with the object? It might be a better way to pass some settings without the deepclone stuff.

Thank you so much :smiley:

To explain what I’m doing with the object, I’ll have to post you another question.
Do you allow me to open an other ticket ? :wink:

Feel free to do it (if it can’t be in one topic).

See you soon :stuck_out_tongue: