These are chat archives for ractivejs/ractive

3rd
Mar 2018
kouts
@kouts
Mar 03 2018 16:36
Anyone knows what is the equivalent of on-click="@this.parent.fire('myevent', @context)" using the proxy array syntax :tm:
Paul Maly
@PaulMaly_twitter
Mar 03 2018 16:47
Just fire event and listen it in parent
on-click=“myevent”
<child on-myevent=“myevent”>
But I prefer (in parent):
on: { ‘child.myevent’: () => {} }
kouts
@kouts
Mar 03 2018 17:08
I'm trying to fire an event (that is defined on the parent) from a child.
Cerem Cem ASLAN
@ceremcem
Mar 03 2018 17:35
@kouts if child should know about the parent internally, isn't it breaking the component architecture?
Joseph
@fskreuz
Mar 03 2018 17:55
The descendants shouldn't be aware of its ancestors, otherwise it becomes coupled. Just let the event bubble. More on component event propagation here https://ractive.js.org/concepts/#component-propagation
Reminds me of the time I saw jQuery code that went like $(this).parent().parent().parent().parent().find('something').click() :grin:
Paul Maly
@PaulMaly_twitter
Mar 03 2018 18:11
Yep, I just talking about event bubbling. So, you need to handle child’s event in parent instead of trigger parent’s event from child.
Chris Reeves
@evs-chris
Mar 03 2018 18:24
you can use '*.event' to listen to any events from the current instance down
kouts
@kouts
Mar 03 2018 18:28
Ok thanks, I'm just creating a mockup and needed a quick n dirty solution
:smile:
kouts
@kouts
Mar 03 2018 18:36
used @evs-chris solution
:thumbsup:
Cerem Cem ASLAN
@ceremcem
Mar 03 2018 18:37
I didn't understand @evs-chris ' solution
how can I display a message from foo in this example?
I thought something like this
Cerem Cem ASLAN
@ceremcem
Mar 03 2018 18:51
okay okay, like this
kouts
@kouts
Mar 03 2018 18:52
yes that's it I think
sorry, gitter app is killing me
Cerem Cem ASLAN
@ceremcem
Mar 03 2018 19:03
:+1:
Juan C. Andreu
@andreujuanc
Mar 03 2018 19:33
GUYS
I opened playground to try something
and saw this: "Ractive 1.0.0-edge "
WHAT? When did this happened? D:
Where is the party?
Chris Reeves
@evs-chris
Mar 03 2018 19:34
just the dev branch 😁
we're gonna hit 0.10 soon for a bit first
Juan C. Andreu
@andreujuanc
Mar 03 2018 19:35
Ahhh!!!!!!!!!!
:clap:
Chris Reeves
@evs-chris
Mar 03 2018 19:36
got some changes that might need breaking, and the sentimental versioner in me doesn't want to jump immediately to 2.0
Juan C. Andreu
@andreujuanc
Mar 03 2018 19:36
True
better to have a solid 1
Last playground demo you posted here, had '*.click' so it can listen to child components. Why is that? why not just 'click' from bubbling?
(small curiosity question btw)
Chris Reeves
@evs-chris
Mar 03 2018 19:39
all events bubble, so without the namespace, you might get accidental triggers, especially on lifecycle events like init
Juan C. Andreu
@andreujuanc
Mar 03 2018 19:42
makes sense !
Cerem Cem ASLAN
@ceremcem
Mar 03 2018 22:49