Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Sad that this is every other reaction from the "this is something new, I refuse to try to understand" devs/people...
Yes, js has its limitations, but you wouldn't track every prop on every deeply nested object in any language unless completely necessary. There are ways to have the reactivity trigger, usually by replacing the object completely. But impossible to say without knowing exactly what you're doing with what framework. -
12bitfloat1026648d@ScriptCoded How is this sad and how am I a bad dev because of it? I had a bad experience from dumb APIs
I'm not here to shit on js (i actually like js now) but wtf
"just recreate the entire object" okay sure, is there an easy way to do that? Not that I know. Apart from the fact that incrementing a single number now turned into "just deep copy an entire object tree" -
@12bitfloat Never said you were a bad dev, never would.
Usually you can just spread. So something like this
x = {
...x,
y: x.y + 1
} -
12bitfloat1026648d@ScriptCoded That doesn't do a deep copy though
I guess my problem is somewhat atypical because I'm trying to update a field of an object in an reactive array from an event listener (which doesn't know which entry in the array is "me")
I don't know. Maybe I should just finally switch to react, but it still doesn't feel right. Surely there has to be a better answer than "deep copy your entire application state" from an architectural perspective -
Ranchonyx1040148dIf you really, REALLY need to track changes in deeply nested objects, look into proxies. You can recursively create proxy trees.
It's shit, really inefficient, but if you really gotta "deeply" track an object, yeah.
But if you're at this point, you may wanna rethink your architecture. -
spongessuck613248dYou can also do it with a reducer that assembles your global application state from its parts.
-
@12bitfloat you are not really deep-copying anything iirc. You do from the programmer pov, but in memory things are handled smartly.
I don't understand what the problem is. You have an object change you're trying to react to, but it doesn't trigger the change? Sounds like an issue with your algorithm.
Related Rants
Reactive state tracking in JS frontend frameworks is just ridiculous
This is a language that encourages you to create huge trees of objects but from what I can tell most frameworks have real trouble detecting any change more complex than a direct assignment
Am I missing something? I have a reactive list of objects of which fields get updated. I have no idea how to make that trigger UI updates.... This is just torture
rant
webdev
wtf
js