Events
We will try to understand everything about events in this post.

Events is one of the most interesting and fun to work with concept in JavaScript.
Let me try to explain Events in layman terms. HTML document will be having whole bunch of tags with in it and when ever we want to associate some dynamism to any of the elements we will be using events.
Let me take a simple button
<button class="slds-btn">Click me!!!</button>
If I were to provide some dynamic behaviour to the button am gonna add an Event Listener to it. A typical event listener is going to look like this.
const btn = document.querySelector('button');
btn.onclick = function() {
console.log('HEY Salesforce Casts!!!');
}
Simple right ...
Now I can just remove the console.log()
statement in the Event Listener and I can put some code to even make an Ajax callout.
In this post we will be looking at everything that we need to understand about events.
- what are Events in JavaScript
- How to implement events in LWC
- Dispatching an event
- Different variants of events in LWC
-
bubbles: true && composed: false
- event bubbling in the present component and containing component
- event bubbling only in containing component
- Passing data with Events
- Programatically handle events
- Event retargeting in LWC
- PubSub, a Library to handle events
- Lightning Messaging Service