SlideShare a Scribd company logo
1 of 13
Salesforce Admin Group, Trichy
A Review on LWC Events
Salesforce Admin Group,Trichy
Speaker
Kadhar Basha Jamal Mohamed
Today’s Agenda
• Introduction
• Types of Events
• Scenarios
• Demo
• Questions & Answers
DOM Events
• HTML DOM events allow JavaScript to register
different event handlers on elements in an HTML
document.
• Events are normally used in combination with
functions, and the function will not be executed
before the event occurs (such as when a user clicks a
button).
Behavior DOM of Events
• In Lightning Web Components, we can create and dispatch custom
events. Events are utilized to communicate up the component
containment hierarchy.
• Event Target Interface is implemented in LWC to dispatch, listen
to, and handle events.
• The elements involved in the DOM Events System are:
• An Event Name, known as Type.
• Configuration in order to initialize an event.
• A JavaScript Object that emits the event.
Types of Events
• Parent – to – Child Communtication
• Child-to-Parent Communication
• Communication Between Unrelated Components
• Lightning Message Service
Parent-Child scenario
To pass the details from a parent-to-child
component, public methods or public properties can be
used.
An API Decorator should be used to expose the child
component properties/methods available to the parent
component.
Child-Parent scenario
Custom Event can be used to communicate from child component to
parent component.
CustomEvent() constructor can be used to create a custom event. Custom
Event Name and properties should be passed into the constructor.
The dispatchEvent() method is used to dispatch an event, and the code
looks like this:
this.dispatchEvent(newcustomEvent(eventName, props);
EventTarget.dispatchEvent()
To handle an Event declaratively with a HTML markup, add “on” as a prefix
keyword for the event name in the parent component when calling the
child component for the declarative event listener.
Unrelated Component scenario
Communication between components which aren’t in the
same DOM tree (unrelated components) can be achieved
by using the publish-subscribe model. Essentially, one
component subscribes to an event, whereas another
component publishes the event and handles it in the same
scope.
Lightning Message Service scenario
Communication between components which aren’t in the
same DOM tree (unrelated components) can be achieved
by using the publish-subscribe model. Essentially, one
component subscribes to an event, whereas another
component publishes the event and handles it in the same
scope.
DEMO
A Review on LWC Events for communication.pptx
A Review on LWC Events for communication.pptx

More Related Content

Similar to A Review on LWC Events for communication.pptx

JavaScript_Events.pptx
JavaScript_Events.pptxJavaScript_Events.pptx
JavaScript_Events.pptxYagna15
 
Event+driven+programming key+features
Event+driven+programming key+featuresEvent+driven+programming key+features
Event+driven+programming key+featuresFaisal Aziz
 
Milwaukee JS - Live binding with CanJS
Milwaukee JS - Live binding with CanJSMilwaukee JS - Live binding with CanJS
Milwaukee JS - Live binding with CanJSStan Carrico
 
Routed events in silverlight
Routed events in silverlightRouted events in silverlight
Routed events in silverlightmsarangam
 
WEB TECHNOLOGY Unit-4.pptx
WEB TECHNOLOGY Unit-4.pptxWEB TECHNOLOGY Unit-4.pptx
WEB TECHNOLOGY Unit-4.pptxkarthiksmart21
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
02 wp7 building silverlight applications
02 wp7   building silverlight applications02 wp7   building silverlight applications
02 wp7 building silverlight applicationsTao Wang
 
Flex Building User Interface Components
Flex Building User Interface ComponentsFlex Building User Interface Components
Flex Building User Interface ComponentsAhmad Hamid
 
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)Nuzhat Memon
 
Step talk
Step talkStep talk
Step talkESUG
 
Javascript dom event
Javascript dom eventJavascript dom event
Javascript dom eventBunlong Van
 
Data Sharing Between Child and Parent Components in AngularJS
Data Sharing Between Child and Parent Components in AngularJSData Sharing Between Child and Parent Components in AngularJS
Data Sharing Between Child and Parent Components in AngularJSFibonalabs
 
Advanced designs for reusable lightning components
Advanced designs for reusable lightning componentsAdvanced designs for reusable lightning components
Advanced designs for reusable lightning componentsthomaswaud
 
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSSeminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSMizanur Sarker
 
INTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMINGINTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMINGProf Ansari
 

Similar to A Review on LWC Events for communication.pptx (20)

Html bridge
Html bridgeHtml bridge
Html bridge
 
JavaScript_Events.pptx
JavaScript_Events.pptxJavaScript_Events.pptx
JavaScript_Events.pptx
 
Event+driven+programming key+features
Event+driven+programming key+featuresEvent+driven+programming key+features
Event+driven+programming key+features
 
Milwaukee JS - Live binding with CanJS
Milwaukee JS - Live binding with CanJSMilwaukee JS - Live binding with CanJS
Milwaukee JS - Live binding with CanJS
 
Routed events in silverlight
Routed events in silverlightRouted events in silverlight
Routed events in silverlight
 
Session 5#
Session 5#Session 5#
Session 5#
 
WEB TECHNOLOGY Unit-4.pptx
WEB TECHNOLOGY Unit-4.pptxWEB TECHNOLOGY Unit-4.pptx
WEB TECHNOLOGY Unit-4.pptx
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
02 wp7 building silverlight applications
02 wp7   building silverlight applications02 wp7   building silverlight applications
02 wp7 building silverlight applications
 
Flex Building User Interface Components
Flex Building User Interface ComponentsFlex Building User Interface Components
Flex Building User Interface Components
 
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
Std 12 Computer Chapter 2 Cascading Style Sheet and Javascript (Part-2)
 
Web programming
Web programmingWeb programming
Web programming
 
Step talk
Step talkStep talk
Step talk
 
Javascript dom event
Javascript dom eventJavascript dom event
Javascript dom event
 
Javascript and DOM
Javascript and DOMJavascript and DOM
Javascript and DOM
 
Data Sharing Between Child and Parent Components in AngularJS
Data Sharing Between Child and Parent Components in AngularJSData Sharing Between Child and Parent Components in AngularJS
Data Sharing Between Child and Parent Components in AngularJS
 
Advanced designs for reusable lightning components
Advanced designs for reusable lightning componentsAdvanced designs for reusable lightning components
Advanced designs for reusable lightning components
 
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRSSeminar - Scalable Enterprise Application Development Using DDD and CQRS
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
 
WP - Unit I.ppt
WP - Unit I.pptWP - Unit I.ppt
WP - Unit I.ppt
 
INTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMINGINTRODUCTION TO CLIENT SIDE PROGRAMMING
INTRODUCTION TO CLIENT SIDE PROGRAMMING
 

More from KadharBashaJ

Winter'23 Release Updates.pptx
Winter'23 Release Updates.pptxWinter'23 Release Updates.pptx
Winter'23 Release Updates.pptxKadharBashaJ
 
Asynchronous Apex .pptx
Asynchronous Apex .pptxAsynchronous Apex .pptx
Asynchronous Apex .pptxKadharBashaJ
 
Review on Data Security.pptx
Review on Data Security.pptxReview on Data Security.pptx
Review on Data Security.pptxKadharBashaJ
 
Flow With Aura.pptx
Flow With Aura.pptxFlow With Aura.pptx
Flow With Aura.pptxKadharBashaJ
 
Flow builder series i
Flow builder series iFlow builder series i
Flow builder series iKadharBashaJ
 
Tour to docgen lightning experience
Tour to docgen lightning experienceTour to docgen lightning experience
Tour to docgen lightning experienceKadharBashaJ
 
Winter 22 features
Winter 22 featuresWinter 22 features
Winter 22 featuresKadharBashaJ
 
DocuSign Power Form
DocuSign Power FormDocuSign Power Form
DocuSign Power FormKadharBashaJ
 
Publish and subscribe platform events using flows
Publish and subscribe platform events using flowsPublish and subscribe platform events using flows
Publish and subscribe platform events using flowsKadharBashaJ
 
Multi language support for salesforce community portal
Multi language support for salesforce community portalMulti language support for salesforce community portal
Multi language support for salesforce community portalKadharBashaJ
 
Simplified appointment scheduling using lightning scheduler
Simplified appointment scheduling using lightning schedulerSimplified appointment scheduling using lightning scheduler
Simplified appointment scheduling using lightning schedulerKadharBashaJ
 
How to crack Admin and Advanced Admin
How to crack Admin and Advanced AdminHow to crack Admin and Advanced Admin
How to crack Admin and Advanced AdminKadharBashaJ
 
Alternate for scheduled apex using flow builder
Alternate for scheduled apex using flow builderAlternate for scheduled apex using flow builder
Alternate for scheduled apex using flow builderKadharBashaJ
 
How to crack java script certification
How to crack java script certificationHow to crack java script certification
How to crack java script certificationKadharBashaJ
 
Master tableau 20 in data science by solving real life analytics problems
Master tableau 20 in data science by solving real life analytics problemsMaster tableau 20 in data science by solving real life analytics problems
Master tableau 20 in data science by solving real life analytics problemsKadharBashaJ
 
Low code love salesforce automation tool vs apex code
Low code love salesforce automation tool vs apex codeLow code love salesforce automation tool vs apex code
Low code love salesforce automation tool vs apex codeKadharBashaJ
 
Qa mockup interview for automation testing
Qa mockup interview for automation testingQa mockup interview for automation testing
Qa mockup interview for automation testingKadharBashaJ
 
Qa mock up interview for manual testing
Qa mock up interview for manual testingQa mock up interview for manual testing
Qa mock up interview for manual testingKadharBashaJ
 

More from KadharBashaJ (20)

Winter'23 Release Updates.pptx
Winter'23 Release Updates.pptxWinter'23 Release Updates.pptx
Winter'23 Release Updates.pptx
 
Asynchronous Apex .pptx
Asynchronous Apex .pptxAsynchronous Apex .pptx
Asynchronous Apex .pptx
 
Review on Data Security.pptx
Review on Data Security.pptxReview on Data Security.pptx
Review on Data Security.pptx
 
Flow With Aura.pptx
Flow With Aura.pptxFlow With Aura.pptx
Flow With Aura.pptx
 
Conga composer
Conga composerConga composer
Conga composer
 
Flow builder series i
Flow builder series iFlow builder series i
Flow builder series i
 
Tour to docgen lightning experience
Tour to docgen lightning experienceTour to docgen lightning experience
Tour to docgen lightning experience
 
Winter 22 features
Winter 22 featuresWinter 22 features
Winter 22 features
 
DocuSign Power Form
DocuSign Power FormDocuSign Power Form
DocuSign Power Form
 
Formstack
FormstackFormstack
Formstack
 
Publish and subscribe platform events using flows
Publish and subscribe platform events using flowsPublish and subscribe platform events using flows
Publish and subscribe platform events using flows
 
Multi language support for salesforce community portal
Multi language support for salesforce community portalMulti language support for salesforce community portal
Multi language support for salesforce community portal
 
Simplified appointment scheduling using lightning scheduler
Simplified appointment scheduling using lightning schedulerSimplified appointment scheduling using lightning scheduler
Simplified appointment scheduling using lightning scheduler
 
How to crack Admin and Advanced Admin
How to crack Admin and Advanced AdminHow to crack Admin and Advanced Admin
How to crack Admin and Advanced Admin
 
Alternate for scheduled apex using flow builder
Alternate for scheduled apex using flow builderAlternate for scheduled apex using flow builder
Alternate for scheduled apex using flow builder
 
How to crack java script certification
How to crack java script certificationHow to crack java script certification
How to crack java script certification
 
Master tableau 20 in data science by solving real life analytics problems
Master tableau 20 in data science by solving real life analytics problemsMaster tableau 20 in data science by solving real life analytics problems
Master tableau 20 in data science by solving real life analytics problems
 
Low code love salesforce automation tool vs apex code
Low code love salesforce automation tool vs apex codeLow code love salesforce automation tool vs apex code
Low code love salesforce automation tool vs apex code
 
Qa mockup interview for automation testing
Qa mockup interview for automation testingQa mockup interview for automation testing
Qa mockup interview for automation testing
 
Qa mock up interview for manual testing
Qa mock up interview for manual testingQa mock up interview for manual testing
Qa mock up interview for manual testing
 

Recently uploaded

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Recently uploaded (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

A Review on LWC Events for communication.pptx

  • 1. Salesforce Admin Group, Trichy A Review on LWC Events
  • 3. Today’s Agenda • Introduction • Types of Events • Scenarios • Demo • Questions & Answers
  • 4. DOM Events • HTML DOM events allow JavaScript to register different event handlers on elements in an HTML document. • Events are normally used in combination with functions, and the function will not be executed before the event occurs (such as when a user clicks a button).
  • 5. Behavior DOM of Events • In Lightning Web Components, we can create and dispatch custom events. Events are utilized to communicate up the component containment hierarchy. • Event Target Interface is implemented in LWC to dispatch, listen to, and handle events. • The elements involved in the DOM Events System are: • An Event Name, known as Type. • Configuration in order to initialize an event. • A JavaScript Object that emits the event.
  • 6. Types of Events • Parent – to – Child Communtication • Child-to-Parent Communication • Communication Between Unrelated Components • Lightning Message Service
  • 7. Parent-Child scenario To pass the details from a parent-to-child component, public methods or public properties can be used. An API Decorator should be used to expose the child component properties/methods available to the parent component.
  • 8. Child-Parent scenario Custom Event can be used to communicate from child component to parent component. CustomEvent() constructor can be used to create a custom event. Custom Event Name and properties should be passed into the constructor. The dispatchEvent() method is used to dispatch an event, and the code looks like this: this.dispatchEvent(newcustomEvent(eventName, props); EventTarget.dispatchEvent() To handle an Event declaratively with a HTML markup, add “on” as a prefix keyword for the event name in the parent component when calling the child component for the declarative event listener.
  • 9. Unrelated Component scenario Communication between components which aren’t in the same DOM tree (unrelated components) can be achieved by using the publish-subscribe model. Essentially, one component subscribes to an event, whereas another component publishes the event and handles it in the same scope.
  • 10. Lightning Message Service scenario Communication between components which aren’t in the same DOM tree (unrelated components) can be achieved by using the publish-subscribe model. Essentially, one component subscribes to an event, whereas another component publishes the event and handles it in the same scope.
  • 11. DEMO