These are chat archives for ractivejs/ractive

5th
Dec 2017
Anatoli Radulov
@avoto
Dec 05 2017 03:48
@fskreuz vanilla component files is not a bad option too
Anatoli Radulov
@avoto
Dec 05 2017 03:54
Hi All, is it possible to specify the entire data of an isolated component via an attribute? Something like this? <component1 data="{{someLocalValue}}" />
Joseph
@fskreuz
Dec 05 2017 04:17
I vaguely remember having discussions about passing data to a component wholesale. I just couldn't find the PR/issue it was discussed on.
Anatoli Radulov
@avoto
Dec 05 2017 04:29
ah! yes, I found it - ractivejs/ractive#2166
Joseph
@fskreuz
Dec 05 2017 04:33
:+1:
Anatoli Radulov
@avoto
Dec 05 2017 04:33
@fskreuz Thank you!
kouts
@kouts
Dec 05 2017 08:53
so what was the answer finally? :smile:
Paul Maly
@PaulMaly_twitter
Dec 05 2017 09:23
@avoto what is the vanilla component looks like? You mean export in var or global?
@fskreuz I think we can use webpack config to be more flexible. Actually, it doesn't matter which module pattern we use in source library code (I prefer CommonJS2, but it can be ES6). We can just use "library" and "libraryTarget" options in webpack config to build any kind of modules.
Paul Maly
@PaulMaly_twitter
Dec 05 2017 09:30
Developers will be able to do something like:
"npm run build:umd" to get umd package or any other.
kouts
@kouts
Dec 05 2017 11:17
@avoto how did you pass the whole data to the component?
Paul Maly
@PaulMaly_twitter
Dec 05 2017 14:25
@kouts I think it's not so simple. Actually, I don't know any case where I need to reset whole data object, instead of just a setup the key in data. This variant works fine in old Ractive's versions: playground , but not work in newer (((
@evs-chris How do you think, it's an issue or lifecycle events are not bubbling anymore?
kouts
@kouts
Dec 05 2017 14:27
I think @avoto asked how to explicitly pass all the data of the parent to the child
<component1 data="{{someLocalValue}}" />
Paul Maly
@PaulMaly_twitter
Dec 05 2017 14:28
@.get() - all the data of the parent
kouts
@kouts
Dec 05 2017 14:28
I know, but why reset?
Paul Maly
@PaulMaly_twitter
Dec 05 2017 14:29
reset() - Resets the entire ractive.data object and updates the DOM.
kouts
@kouts
Dec 05 2017 14:29
I should be as simple as
<component1 data="{{data}}" />
Paul Maly
@PaulMaly_twitter
Dec 05 2017 14:29
But it's not
kouts
@kouts
Dec 05 2017 14:30
Are other frameworks allow this?
i.e pass all the data from parent to child?
Paul Maly
@PaulMaly_twitter
Dec 05 2017 14:30
Hm, I don't know, because, as I said, I don't know any case to need this.
kouts
@kouts
Dec 05 2017 14:31
A case would be when converting some non isolated components into isolated ones
saves a lot of boilerplate
Paul Maly
@PaulMaly_twitter
Dec 05 2017 14:32
I believe, that @avoto didn't mean "all parent data", because for this point we have isolated: false option.
So, if you need all parent data, just use isolated: false option.
kouts
@kouts
Dec 05 2017 14:33
yes I see now it's something different @avoto asked
Paul Maly
@PaulMaly_twitter
Dec 05 2017 14:33
I use it in modal-window components and other wrapper-components
I think that @avoto asked about setting up some part of parent data as whole data of child
kouts
@kouts
Dec 05 2017 14:34
yes
Paul Maly
@PaulMaly_twitter
Dec 05 2017 14:35

I don't know any other solution exept this one:

<subcomponent on-init="@event.component.reset(@.get('someLocalValue'))"></subcomponent>

And it also bad solution
Also, it seems that on-init lifecycle event not bubbling on latest versions, weird. (((
Chris Reeves
@evs-chris
Dec 05 2017 15:03
lifecycle events should definitely bubble, and if they're not, it's a bug
Paul Maly
@PaulMaly_twitter
Dec 05 2017 15:03
ok, then I'll submit an issue
Chris Reeves
@evs-chris
Dec 05 2017 15:05
the safest way to pass all parent data to a child component is using a specific member e.g. <child data={{~/}} orMaybe={{.}} />
stuff tends to get weird when you can't have component private data, but we can always look at #2166 again
Paul Maly
@PaulMaly_twitter
Dec 05 2017 15:08
I think it's strange case. If you need to get all parent data in child, just use isolated option.
But it definitely bad design
kouts
@kouts
Dec 05 2017 15:11
Depends what the role of your component is and how your data is structured.
Paul Maly
@PaulMaly_twitter
Dec 05 2017 15:56
H.
Hm, if you use isolated: false you still able to use some private data in child, but if we manually pass whole data from parent then no.