How do I use reflection to call a generic method? how to get the for"each value in get method in LWC javascript, How to pass Dynamic ID to href link in Lightning web components, Set CSS class dynamically in Lightning web component, Lightning Components: expression inside fails, Lightning Web Components Easy Spaces sample application LWC component code. The parent component listens for the event with the inline event handler prefixed with 'on'(onnext). Can non-Muslims ride the Haramain high-speed train in Saudi Arabia? When you dispatch custom event, you need to add "on" before event name/type if you are handling event directly during declaration. Standard DOM events should always be your first choice for events because they only travel up the containment hierarchy, making behavior more predictable. Now moving towards the parent component, declare one variable in the parent component to pass it to the child component. Rename .gz files according to names in separate txt-file. And implement in there the logic that @POZ suggested. ', "Invalid event listener '{0}' on slot. When the c-video-player component is included in a parent component, we can invoke the method from the parent component like this: We defined a method handlePlay() that fires the event. Also, you can use getters & setters to execute some logic when properties are get or set. If you're 100% sure your code will never be used in these circumstances then the event signature guideline isn't as important (apart from other developers thinking WTF), but if it might be then you should follow it. Now update parent component javaScript file and add handleCustomEvent method, Lets see how we can use JavaScript using addEventListener method | Attaching event Listener Programmatically, Step 1) We can use the same above sample and do below change in parent component, Update parent component JavaScript like below, Remove onmycustomevent attribute from child component tag. Connect and share knowledge within a single location that is structured and easy to search. Additional info: ', 'lwc:slot-data directive can be used on