Concepts or coding lessons of Salesforce that you can implement easily

2 Basic steps to Create Simple Event in LWC

Below are 2 basic steps to create simple event in LWC:

Step 1 : Create Event using new Custom Event Method

const events =  new CustomEvent("YourEventName");


Step 2 : Dispatch Event using Dispatch Event Method

this.dispatchEvent(events);


for example: 

childcmp.js

import { LightningElement} from 'lwc';

export default class ChildCmp extends LightningElement {

    handleEvent(){
        // create event
        const events =  new CustomEvent("sampleEvent");
       
        // dispatch event
        this.dispatchEvent(events);
    }
}