These are chat archives for ractivejs/ractive

11th
Jun 2018
Cerem Cem ASLAN
@ceremcem
Jun 11 2018 09:58
Here is a question: When I need to update a variable, I must do the following:
x = this.get('myobj');
x.foo.bar.baz = 5
this.set('myobj', x);
same thing can be performed with update() method:
x = this.get('myobj');
x.foo.bar.baz = 5;
this.update('myobj');
kouts
@kouts
Jun 11 2018 09:59
or this.set('myobj.foo.bar.baz', 5);
Cerem Cem ASLAN
@ceremcem
Jun 11 2018 10:01
I think they have the exact same effect at this point. My question is, would it be more performant to use update over set if we exactly tell the changed keypath, eg.
this.update('myobj.foo.bar.baz');  // is it more performant for a very large object?
@kouts you're also correct, but most of the times I need to access to the full object for for loops, existence checks etc.
kouts
@kouts
Jun 11 2018 10:06
If that's the case I always make a deep copy of the data, make the changes there and then use one this.set('keypath', toset) at the end
Cerem Cem ASLAN
@ceremcem
Jun 11 2018 10:08
does "deep copy" means "toset = JSON.parse(JSON.stringify(myobj)"?
kouts
@kouts
Jun 11 2018 10:09
yes
I'm sorry, I'm mistaken, I don't do a deept clone in this case
I just gather all the changes in one toset object
(no need to deep copy here)
and then set that object
(forget the deep clone part :smile: )
Joseph
@fskreuz
Jun 11 2018 12:03

would it be more performant...

The usual response I give would be "check the profiler" :D

But from a readability point of view, assuming they have the same effect, I would do the second example (get object, mutate it, then call update).
update implies you mutated data without Ractive knowing you did it (which fits your description) while set is more of "set new value" which it sort of isn't (unless you deep copy, which is another story).
Joseph
@fskreuz
Jun 11 2018 15:04
Random question of the day: React released their Context API. From a quick glance, it looks like something you can achieve in Ractive with {{# with }}, or sticking stuff in a component with a {{> content }} or {{yield }} and carrying its own data, or using a data instance, or even @shared. Thoughts?
kouts
@kouts
Jun 11 2018 15:09
yes it seems something like @shared
kouts
@kouts
Jun 11 2018 15:22
Ractive makes it so much simpler
:smile:
Paul Maly
@PaulMaly_twitter
Jun 11 2018 16:23
Ractive === awesome! React !== awesome
Chris Reeves
@evs-chris
Jun 11 2018 17:14
weird... their example is pretty much just ractive cssdata
which, coincidentally, doesn't have to be used for styles
Paul Maly
@PaulMaly_twitter
Jun 11 2018 17:20
For me, React Context is a weird shit
Sorry for my French
Cerem Cem ASLAN
@ceremcem
Jun 11 2018 17:29
@fskreuz thanks for the answer
Cerem Cem ASLAN
@ceremcem
Jun 11 2018 17:43
...the React thing: I simply can't read its code so I don't have any comments about it
Cerem Cem ASLAN
@ceremcem
Jun 11 2018 18:43
question: should we call the users of Ractive as "Ractivists"?
Chris Reeves
@evs-chris
Jun 11 2018 18:51
I've heard that term before
I also like ractivators - looks kinda like an internet fighter pilot
has this page been ractivated?
Joseph
@fskreuz
Jun 11 2018 18:58
Given Ractive's backstory, "ractive" is an interactive interface. "ractor" is the actor behind it. :smile:
The relationship would be like: You -> Windows -> Cortana (or an army of engineers and a voice actor, realistically) :grin:
Chris Reeves
@evs-chris
Jun 11 2018 19:03
ractors! That's other one...
sounds dinosaury or bird-of-prey-y depending on whether have a biology bent or were a kid when Jurassic Park came out 😁
Joseph
@fskreuz
Jun 11 2018 20:02
When I hear "ractor", I imagine "tractor" and therefore :truck:
Chris Reeves
@evs-chris
Jun 11 2018 20:47
:ship:
Cerem Cem ASLAN
@ceremcem
Jun 11 2018 21:16
I like "ractor" :)
Paul Maly
@PaulMaly_twitter
Jun 11 2018 21:16
I like "tractor" )))
I love big vehicles!