These are chat archives for ractivejs/ractive

12th
Oct 2018
Joseph
@fskreuz
Oct 12 2018 12:18
Friday! :tada:
Chris Reeves
@evs-chris
Oct 12 2018 13:36
:tada:
Arnaud Dagnelies
@dagnelies
Oct 12 2018 13:59
:tada:
kouts
@kouts
Oct 12 2018 14:18
:fireworks:
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 15:08
pcb-test.gif
this is the first working version of svg interaction which uses only Ractive.
Chris Reeves
@evs-chris
Oct 12 2018 15:12
nice!
related question: do you have an algorithm for distributing nodes in a sort of parallel flow chart or dependency graph?
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 15:16
I don't think so, and I'm not sure what it means. which nodes? the blue ones?
Chris Reeves
@evs-chris
Oct 12 2018 15:17
yes
suppose you had 200 blue nodes in a multi-rooted overlapping tree and you wanted to display them with the roots at the top and branches near their roots but overlapping as little as possible
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 15:22
an example use case would help understanding, but I think I got it: no, currently not but it has to be implemented
suppose this SVG is a table and these footprints (there are two "Ball Grid Array footprints" here where each has 16 pins) are play cards
we want to throw the cards onto the table and we want them to touch each other without overlapping. did I understand correctly?
Chris Reeves
@evs-chris
Oct 12 2018 15:25
sounds like it, yes
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 15:27
okay then. it won't be a super priority, but has to be implemented in a circuit design application
my question: this approach works, but designing a circuit requires many components to be defined very quickly, so I think I'll need a domain specific language for this
Chris Reeves
@evs-chris
Oct 12 2018 15:30
certainly wouldn't hurt to have an input where you could list out components and have them be created for you
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 15:30
this is a valid json actually: https://gist.github.com/ceremcem/14b3c1105a12f434b6f829fa88e23109 (not finished, of course) Once it finish, I think I can use the data to create parsed Ractive templates which will run on top of Ractive application. do you think that will work?
Chris Reeves
@evs-chris
Oct 12 2018 15:32
I think I would just wrap a ractive template around that structure instead of trying to generate a template
then the template can remain reactive to changes in the data structure too rather than just prop changes
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 15:34
hmm. you say I should use this as data: ... and make a properly designed Ractive template interpret this data?
Chris Reeves
@evs-chris
Oct 12 2018 15:34
using full components for complicated designs would probably have perf issues
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 15:42

using full components for complicated designs would probably have perf issues

I think I remember this topic. Is the performance criteria related with number of components defined or the instance count?

Chris Reeves
@evs-chris
Oct 12 2018 15:43
instance count
each component instance has a fair amount of overhead
as long as you keep it less than 1000 you're usually ok, but you'll definitely see some perf hit at greater than 100
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 15:46
oh, I just headed to define the wire component, where a typical circuit has 500~1000 of them. good to be warned here
Chris Reeves
@evs-chris
Oct 12 2018 15:47
dynamic partials are very sightly heavier than plain partials, but they cover a good bit of component functionality without the extra weight
macros that is
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 15:50
dynamic partials? do we have such thing? :)
you mean, dynamic partials = macros
Chris Reeves
@evs-chris
Oct 12 2018 15:51
closely related - got my terms confused
Joseph
@fskreuz
Oct 12 2018 16:23
If you'll end up with hundreds of instances and perf becomes an issue, you might want to consider using canvas.
I think the 2016 Guardian election map used Ractive instances that wrapped canvases. Each instance controlled a section of the app.
This would mean Ractive would be demoted to a inter-model/inter-component messaging interface to control the canvas. All drawing done on a canvas.
This way, you could take advantage of more optimized drawing libraries.
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 16:30
this will bring us back to square one
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 16:48
besides the performance concerns, there seems some other issues taken into account: svg does not have boolean operation support, which will force me using a third party library (clipper.js) anyway
question: can I perform a MITM right before Ractive updates the HTML?
Chris Reeves
@evs-chris
Oct 12 2018 16:53
in what way?
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 16:53
for example, I'll generate a javascript code using Ractive and run the output just like a source code (ie. inject into <script> tags)
Chris Reeves
@evs-chris
Oct 12 2018 16:55
if I understand you correctly, there's a plain text mode on the parser for stuff like that
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 17:34
there is a transform property available for Ractive.parse but isn't it a one-shot parsing operation? I mean, Ractive won't optimize small portion changes
I thought something like
foo = Ractive.extend({
  template: ..., 
  transform: function(output){
    // do something with the output 
    return output; // this will be optional: if omitted, it will be like we have an empty template in the first place
  }
});
Chris Reeves
@evs-chris
Oct 12 2018 17:54
that's for transforming the ast, but was removed in 0.10, I think
those docs need to be updated
transforms were experimental and were replaced by macros
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 23:23
@evs-chris have you ever used a parser generator, like Peg.js? I'm wondering if they are really worth to learn
Chris Reeves
@evs-chris
Oct 12 2018 23:26
I've used parser combinators extensively in scala, and a peg parser is on my list of things to look at, but I haven't gotten round to it yet
my understanding is that peg.js is pretty good
if/when ractive gets a parser redo, that's the first place I'll be looking
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 23:47
wow, thanks. so it's better to learn such a tool before creating a (domain specific) language.
Chris Reeves
@evs-chris
Oct 12 2018 23:48
it's definitely helpful if you've never written a parser before
if you don't have any funky constructs in the grammar, it should even be pretty easy
Cerem Cem ASLAN
@ceremcem
Oct 12 2018 23:49
my previous parsers are mess, I can't read and/or modify them now.
the only trick I know is using regex. but regex is "write once and forget about reading it ever" IMHO
Chris Reeves
@evs-chris
Oct 12 2018 23:56
I get by with regex, but @MartinKolarik is a regex wizard