These are chat archives for ractivejs/ractive

28th
Jun 2018
Cerem Cem ASLAN
@ceremcem
Jun 28 2018 13:46
hi
I can't recall how we perform the filtering and sorting operations over arrays (or objects). @evs-chris you had implemented an integrated (and efficient) way to perform these, right?
Chris Reeves
@evs-chris
Jun 28 2018 15:34
you can have it behave as a splice and have the context map back to a source array
doesn't work with objects though
Chris Reeves
@evs-chris
Jun 28 2018 16:28
was looking into built-in filtering, but it's hard to get right in a general way, not to mention pushback on an ever expanding api :)
Joseph
@fskreuz
Jun 28 2018 16:37
meme.jpeg
Cerem Cem ASLAN
@ceremcem
Jun 28 2018 16:50
:smile:
Cerem Cem ASLAN
@ceremcem
Jun 28 2018 17:43
I think sorting the array (or converting the object beforehand) in background is the way to go
for example, I needed to sort the columns. (I agree that) this would be a pain for Ractive to handle all the corner cases
Chris Reeves
@evs-chris
Jun 28 2018 18:09
since nested loops are not so great for efficiency, my approach has generally been to do the column sorting once, generate a partial, and use it in the main loop
waaay faster for render
and you can always swap out the partial if you need to re-sort the columns
Cerem Cem ASLAN
@ceremcem
Jun 28 2018 18:10
sorting with partials? o_O I'm not sure I understood the approach
Chris Reeves
@evs-chris
Jun 28 2018 18:33
if you have a list of columns, like ['foo', 'bar', 'baz'], instead of {{#each rows as row}}{{#each cols as col}}{{row[col]}}{{/each}}{{/each}}, {{#each rows}}{{>colPartial}}{{/each}} where colPartial is { template: '{{.foo}}{{.bar}}{{.baz}}' } (or something along those lines)
flatten out the inner loop
unless I misunderstood your scenario
Shakeel Osmani
@shakeelosmani
Jun 28 2018 23:11
I need help with another issue that I am trying to figure out. I have three input fields and one computed value. However three of them are kind of inter dependent and I am having issues making it to work correctly. Here is the fiddle: https://jsfiddle.net/rana_tigrina2002/et9o8hwa/
Also on the JavaScript I have left comments for the expectation of the script
Chris Reeves
@evs-chris
Jun 28 2018 23:16
if you want bindable computeds, you'll need to supply setters
I would do it with two-way=false and on-change listeners, though
Shakeel Osmani
@shakeelosmani
Jun 28 2018 23:20
So there is no way to get around this without doing event listeners
Or perhaps I didn't understand this part: "if you want bindable computeds, you'll need to supply setters"
Chris Reeves
@evs-chris
Jun 28 2018 23:23
sorry, on mobile, but yeah
there's an example there
the object with get and set version allows use in bindings
Shakeel Osmani
@shakeelosmani
Jun 28 2018 23:33
cool, thanks,I will try it out and post here. :smile:
Chris Reeves
@evs-chris
Jun 28 2018 23:34
you may need a lock var if computeds can update computeds to avoid inception 😀