You need to sign in to do that
Don't have an account?
B Karthickeyan
What are events in LWC?
I would like to know what are the Events available in LWC and Aura components?
and how it can be utilized effectively(with example)?
and how it can be utilized effectively(with example)?
Events in LWC Are Same As JavaScript Events For Example Like OnClick OnChange And So On Or Like Custom Event By Using Add Event Listener
Click Teh below Link To Know More
LWC Events (https://lwc.dev/guide/events)
Please Mark It As Best Answr If It Helps
Thank You!
For example purpose you can check the link which is given here:
Events Available in Aura:
1. Component Event :This event works for only those which have parent - child relationship or under same DOM hierarchy
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_component_example.htm
2. Application Event:This event works for unrelated component or which have no relationship with each other.
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/events_application_example.htm
Events Available in LWC:
1. Communicate from Child to Parent
2. Communicate from Parent to Child
3. Communicate between unrelated components
https://trailhead.salesforce.com/en/content/learn/projects/communicate-between-lightning-web-components
Please Mark it as Best Answer if it helps!
Thanks
Events in Lightning Web Components (LWC) and Aura components are mechanisms for communication between components in the Lightning Component Framework. They allow components to interact with each other, pass data, and respond to actions without direct dependencies. There are several types of events available in both LWC and Aura. Below, Provide an overview of common event types and how they can be utilized effectively with examples :
Component Events :
- Purpose : These events allow communication between components in a containment hierarchy. A child component can dispatch a component event, and a parent component or an ancestor can handle it.
- Example : Imagine a parent component with a child component. When the user clicks a button in the child component, a component event is fired, and the parent component handles it to perform some action.
Application Events (Aura) / PubSub (LWC) :- Purpose : These events provide a way to communicate between components across the Lightning App. They are suitable for scenarios where components are not in a containment hierarchy.
- Example : Multiple components on a Lightning page can subscribe to a common application event. When an event is fired, all subscribers can react to it. This is similar to the publish-subscribe pattern.
Standard Events :- Purpose : Salesforce provides a set of standard events for common actions like opening a record, saving, or canceling changes.
- Example : You can use the force:refreshView event in Aura to refresh a record view after a change is made.
Additionally, if you're interested in learning about custom events in Salesforce, I recommend checking out the article at https://logcodes.com/lwc-custom-event-in-salesforce/ .This resource provides a comprehensive guide on custom events in Salesforce, complete with a step-by-step tutorial and examples to help you understand and use custom events effectively.