These are chat archives for ractivejs/ractive

16th
Jun 2017
Joseph
@fskreuz
Jun 16 2017 10:12
Anyone use Ractive with some fancy architecture? Time to document that! ractivejs/ractivejs.github.io#73 Your input is appreciated.
Bob Schellink
@sabob
Jun 16 2017 15:20
Thanks for writeup, good info there. In the section "Data in, event out" the parent twoway binding is set to false so that the data mapped to child isn't bound. But that means twoway is off for the entire parent instance. Is it possible to pass data oneway to the child without switching off twoway for entire parent?
Joseph
@fskreuz
Jun 16 2017 20:29
Yup. The parent can be two-way, while the child is one-way. I just stuck two-way:false to everything since I used to do this procedure this way. :D
Bob Schellink
@sabob
Jun 16 2017 22:33
Does data mapping break the "data in event out" rule a bit? When a data mapping is established, setting the value in the child will update the parent as well. Here is a demo with twoway false for both parent and child components. But because of the data mapping between parent:name and child:msg, updating "msg" in child will update "name" in parent. If this breaks the rule is there another way to pass data in without the child being able to update the parent?
Chris Reeves
@evs-chris
Jun 16 2017 22:35
You can use a static mustache to avoid setting up a mapping
that will just pass in the value as long as it's not an object
you can also use an expression to avoid mappings because computations can't update their source models
<someComponent name="{{outer.name + ''}}" />
ractive will only create mappings if the attribute has a single non-static reference-only interpolator as its content - same as twoway bindings on form elements
using a static interpolator results in an initial set if possible
everything else results in a fragment binding that will update the value in the component whenever the value of fragment changes
Bob Schellink
@sabob
Jun 16 2017 23:06
Mostly interested in passing an object such as person. Data mapping is probably the wrong mechanism to pass initial data to the child for that workflow item.
Chris Reeves
@evs-chris
Jun 16 2017 23:16
yep
I typically use lodash cloneDeep and isEqual for those scenarios
Bob Schellink
@sabob
Jun 16 2017 23:19
unmanaged components seems easier for this use case, where one can configure the child beforehand using child.set('person', person) and then attaching it to parent. No data mapping required.
Chris Reeves
@evs-chris
Jun 16 2017 23:20
you have to be careful with that though, because set('person.location.address', '123 any st') will result in the parent data updating but not in sync
when something causes the parent model to invalidate, it will match the child value
Bob Schellink
@sabob
Jun 16 2017 23:35
Btw it seems unmanaged components supersede managed ones. Wonder if there is a use case for managed ones, unless it is about the syntax: anchor vs custom-element?
Chris Reeves
@evs-chris
Jun 16 2017 23:36
yep
managed are for widget things and anchors are for views
at least, that was the goal