These are chat archives for ractivejs/ractive

3rd
Jan 2018
Joseph
@fskreuz
Jan 03 2018 02:40
Just leaving this here for additional eyes ractivejs/ractive#3170
Anatoli Radulov
@avoto
Jan 03 2018 05:40
Anyone has any experience where the last element of an array would not get removed when doing ractive.splice() ? My setup is rather complicated and so far it seems related to me calling ractive.get() in a computed value, which hits a value which is produced by a {{#with}} block. I might try and setup a playground and reproduce it, but because I've never experienced this before I thought one of you guys might've encountered this, which might save me time trying to reproduce it in a simpler setup...
Chris Reeves
@evs-chris
Jan 03 2018 06:17
sounds like it may be a race condition somewhere, but yeah, definitely try to get a repro if you can
Anatoli Radulov
@avoto
Jan 03 2018 06:28
yep, it is definitely some race condition. I'll put some time aside tomorrow to reproduce it. I've found a workaround, but I am not happy with it because it looks very hackish.
Workaround:
If I hide the virtual DOM via some flag prior to the splice, then the splice works fine. Eg. this.set('items.'+ind+'.deleted', true) ; this.splice('items',ind); and then in the template {{#if !deleted}} ...some_complex_stuff... {{/if}}
Chris Reeves
@evs-chris
Jan 03 2018 06:29
are there any errors on the console?
Anatoli Radulov
@avoto
Jan 03 2018 06:29
nope
but one of my components used inside this #each section has a computed value which uses many this.get() calls to filter out a list.
if I don't do the this.get() inside that computed block things are working as expected
It is quite strange.
Chris Reeves
@evs-chris
Jan 03 2018 06:31
on the plus side, there's no hard broken internal state if it never throws
Anatoli Radulov
@avoto
Jan 03 2018 06:31
yep
I'll make a nice playground reproduction tomorrow :)
The funniest part it that it only happens on the last element of the array haha
kouts
@kouts
Jan 03 2018 10:18
are you looping backwards when splicing?
Anatoli Radulov
@avoto
Jan 03 2018 16:24
nope, just a plain {{#each splicable}} ... {{/each}}