These are chat archives for ractivejs/ractive

25th
Jul 2018
Chris Reeves
@evs-chris
Jul 25 2018 00:47
you can pass an init-ish object after the macro function that has an attributes list, and then it will be in attrs passed to update
there are probably other ways too, but my interwbs have been killed by lightning at home, so I'll poke at it when I get a workstation with a keyboard
Cerem Cem ASLAN
@ceremcem
Jul 25 2018 05:07
oh, sorry about that
Cerem Cem ASLAN
@ceremcem
Jul 25 2018 06:17

I'm putting this here, if you can take a look when you have time: Playground
Problem: This setup updates the code value, but affects across all instances where I need to interact with variables privately.

I'm using getVars to determine what to observe. do you think this is appropriate?

Chris Reeves
@evs-chris
Jul 25 2018 18:26
I think the easiest way to skirt it would be to use the content partial of the placeholder, which you can wire up with a macro, but there's also built-in support using an async component
Cerem Cem ASLAN
@ceremcem
Jul 25 2018 18:38
sorry, but it won't work for my case, because my goal is converting sync component into an async one without needing to touch to the user/application code
Chris Reeves
@evs-chris
Jul 25 2018 18:39
ah
is your goal in the example to have a placeholder?
Cerem Cem ASLAN
@ceremcem
Jul 25 2018 18:39
I thought I can require a LOADING postfixed component
Chris Reeves
@evs-chris
Jul 25 2018 18:41
yeah
Cerem Cem ASLAN
@ceremcem
Jul 25 2018 18:42
if you think it is appropriate, I think I can upgrade a component in the runtime
  1. display a simple "we are fetching the component" message
  2. replace the message with fooLOADING component
  3. replace the fooLOADING component with fooASYNC when it is ready
what do you think? is it overkill?
Chris Reeves
@evs-chris
Jul 25 2018 18:42
you should be able to achieve that minimally by using a macro to drop in the async component and provide the supplied template as the async-loading partial
your macro template would be generated (pseudocode) <targetComponent ...attributesFromMacro>{{#partial async-loading}}{{>providedPlaceholder}}{{/partial}}{{>...otherMacroPartials}}</targetComponent>
I could see how it would be very nice for splitting up code for an existing app
Chris Reeves
@evs-chris
Jul 25 2018 18:48
just have to change where the components are referenced/required and not all of the templates
Cerem Cem ASLAN
@ceremcem
Jul 25 2018 18:48
yesss
Chris Reeves
@evs-chris
Jul 25 2018 18:49
dynamically generating a proxy template isn't too bad, but it takes getting a little dirty with the template ast
Cerem Cem ASLAN
@ceremcem
Jul 25 2018 18:50
hmm. I didn't think I would have to do anything fancy

I thought I could define a LOADING component as usual:

Ractive.components.fooLOADING = Ractive.extend(...)

then embed the swapping part into the getSynchronizer() function (macro)

okay, let me create a playground example
Cerem Cem ASLAN
@ceremcem
Jul 25 2018 18:59
Cerem Cem ASLAN
@ceremcem
Jul 25 2018 19:04
this example also shows that we can develop and send a new version of a component to all or some clients in the runtime
ie. hot application upgrading :)