mergeObject

mergeObject is a beast of a function which lets you smash two objects together and that options argument lets you control how exactly you want to merge things. Argument 1: Source Object --> What we are merging into (this is going to be mutated by default) Argument 2: Mod Object --> What we are applying to the Source insertKeys [true] -> If the Mod Object has keys in it which the Source does not have, add those keys to the Source object. insertValues [true] -> If the Source Object's values are objects themselves, this controls whether to merge those values as part of this operation (kind of discount recursive) So for your case:
mergeObject(defaultValues, clientSettingsValues, {
insertKeys: false,
insertValues: false,
});
mergeObject(defaultValues, clientSettingsValues, {
insertKeys: false,
insertValues: false,
});
Where defaultValues is the setting's default, and the clientSettingsValues is the current setting value. This would take the baseline default value and overwrite any existing key/value, but not merge value objects (instead, it would replace them). It'll overwrite because the overwrite option is true by default.
38 Replies
Calego
CalegoOP•4y ago
@mouse0270 what are you up to that isn't workin?
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
aye First one is defaultValues Second one is clientSettingsValues ?
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
so far this is my understanding as well
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
let me guess, you're seeing square-corners in theme balls try adding: recursive: false
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
ok, we're going off the rails here, can you remove the -- from the start of each key?
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
ok good (bad but not super bad)
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
wuuuut You've just hit "escalate to #dev-support on the mothership" territory
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
One more thing to try, clone the object first, then don't do inplace: false
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
(hollering about that, which module did you release under your name again?)
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
đź‘Ť
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
something's real off because if this doesn't work, that's got some big implications
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
norc hooked you up with the right role you should be able to post now @mouse0270 I'd suggest using a minimal reproduction case to keep that channel clean 🙂
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
awesome thanks @mouse0270 Sorry I couldn't get you sorted. I'm hoping this is something stupid we're both missing.
Leo The League Lion
Leo The League Lion•4y ago
@calego gave vote LeaguePoints™ to @mouse0270 (#40 • 43)
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
that only activates if recursive: true though (or should)
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
what in tarnation
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
you could try putting a breakpoint on it and step through to see where it's going wrong in a meeting but I'll see if I can after
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
I understand you now, ugh where's that codyunderthebus
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOP•4y ago
Don't libwrap mergeObject, better to DIY it or work around. There's the off chance that something is relying on this behavior and mergeObject is so prolific in the foundry core that patching it is likely to cause gods knows what issues if this is a bug, that sucks But, right now is the perfect time to find it, as it can get fixed in V9 prototype phase
LukeAbby
LukeAbby•4y ago
I remember running into this when making the Typescrpt type prototype for mergeObject I wasn't sure if it was intentional then still am not
Unknown User
Unknown User•4y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server