Last active
September 19, 2019 19:08
-
-
Save kmesic/020a8c8e5efa703b319e0f14ac9a4b69 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { LightningElement } from 'lwc'; | |
export default class ComponentA extends LightningElement { | |
fireEvent() { | |
// Fire DOM custom event | |
const customEvt = new CustomEvent('custom'); | |
this.dispatchEvent(customEvt); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component | |
access="global" | |
implements="flexipage:availableForAllPageTypes, forceCommunity:availableForAllPageTypes"> | |
<aura:handler event="c:appEvent" action="{!c.handleApplicationEvent}"/> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
handleApplicationEvent : function(component, event) { | |
// Handle the event in your Aura component (component B) | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component | |
access="global" | |
implements="flexipage:availableForAllPageTypes, forceCommunity:availableForAllPageTypes"> | |
<aura:registerEvent name="eventofComponentB" type="c:appEventt"/> | |
<c:component-a oncustom="{!c.handleCustom}"/> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
handleCustom : function(component, event) { | |
var appEvent = cmp.getEvent("eventofComponentB"); | |
// data from lwc event to pass to the aura event | |
appEvent.setParams({"lwcEvent" : event }); | |
appEvent.fire(); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment