Forked from maujood/AppEventLifecycleComponentInner.cmp
Created
February 12, 2020 11:41
-
-
Save saicharanreddyk/2c40134357b87701a997f3623ed95855 to your computer and use it in GitHub Desktop.
Lightning Application Events Demo
This file contains hidden or 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> | |
<aura:attribute name="globalId" type="String"/> | |
<aura:registerEvent name="appEvent" type="c:LightningSimpleEvent"></aura:registerEvent> | |
<aura:handler event="c:LightningSimpleEvent" action="{!c.handleEvent}" phase="capture"></aura:handler> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/> | |
<lightning:layout multipleRows="true"> | |
<lightning:layoutItem size="12" padding="around-small"> | |
Component: {!v.globalId} | |
</lightning:layoutItem> | |
<lightning:layoutItem size="12" padding="around-small"> | |
<lightning:button aura:id="sendEvt" onclick="{!c.sendEvent}" label="Send Event"></lightning:button> | |
</lightning:layoutItem> | |
</lightning:layout> | |
</aura:component> |
This file contains hidden or 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
.THIS { | |
background-color: #999 | |
} |
This file contains hidden or 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
({ | |
doInit: function (component, event, helper) { | |
component.set('v.globalId', component.getGlobalId()); | |
}, | |
sendEvent : function(component, event, helper) { | |
var evt = $A.get('e.c:LightningSimpleEvent'); | |
evt.fire(); | |
}, | |
handleEvent: function (component, event, helper) { | |
console.log('event received by inner controller: ' + component.getGlobalId()); | |
} | |
}) |
This file contains hidden or 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> | |
<aura:attribute name="globalId" type="String"/> | |
<aura:registerEvent name="appEvent" type="c:LightningSimpleEvent"></aura:registerEvent> | |
<aura:handler event="c:LightningSimpleEvent" action="{!c.handleEvent}" phase="capture"></aura:handler> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/> | |
<lightning:layout multipleRows="true"> | |
<lightning:layoutItem size="12" padding="around-small"> | |
Component: {!v.globalId} | |
</lightning:layoutItem> | |
<lightning:layoutItem size="12" padding="around-small"> | |
<lightning:button aura:id="sendEvt" label="Send Event" onclick="{!c.sendEvent}"></lightning:button> | |
</lightning:layoutItem> | |
<lightning:layoutItem size="6" padding="around-small"> | |
<c:AppEventLifecycleComponentInner></c:AppEventLifecycleComponentInner> | |
</lightning:layoutItem> | |
<lightning:layoutItem size="6" padding="around-small"> | |
<c:AppEventLifecycleComponentInner></c:AppEventLifecycleComponentInner> | |
</lightning:layoutItem> | |
</lightning:layout> | |
</aura:component> |
This file contains hidden or 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
.THIS { | |
background-color: #bbb | |
} |
This file contains hidden or 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
({ | |
doInit: function (component) { | |
component.set('v.globalId', component.getGlobalId()); | |
}, | |
sendEvent : function(component, event, helper) { | |
var evt = $A.get('e.c:LightningSimpleEvent'); | |
evt.fire(); | |
}, | |
handleEvent: function (component, event, helper) { | |
console.log('event received by outer controller: ' + component.getGlobalId()); | |
} | |
}) |
This file contains hidden or 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:application extends="force:slds"> | |
<aura:attribute name="globalId" type="String" /> | |
<aura:registerEvent name="appEvent" type="c:LightningSimpleEvent"></aura:registerEvent> | |
<aura:handler event="c:LightningSimpleEvent" action="{!c.handleEvent}" phase="capture"></aura:handler> | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | |
<lightning:layout multipleRows="true"> | |
<lightning:layoutItem size="12" padding="around-small"> | |
Application: {!v.globalId} | |
</lightning:layoutItem> | |
<lightning:layoutItem size="12" padding="around-small"> | |
<lightning:button aura:id="sendEvt" onclick="{!c.sendEvent}" label="Send Event"></lightning:button> | |
</lightning:layoutItem> | |
<lightning:layoutItem padding="around-small" size="6"> | |
<c:AppEventLifecycleComponentOuter></c:AppEventLifecycleComponentOuter> | |
</lightning:layoutItem> | |
<lightning:layoutItem padding="around-small" size="6"> | |
<c:AppEventLifecycleComponentOuter></c:AppEventLifecycleComponentOuter> | |
</lightning:layoutItem> | |
</lightning:layout> | |
</aura:application> |
This file contains hidden or 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
.THIS { | |
background-color: #eee | |
} |
This file contains hidden or 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
({ | |
doInit: function (component) { | |
component.set('v.globalId', component.getGlobalId()); | |
}, | |
sendEvent : function(component, event, helper) { | |
var evt = $A.get('e.c:LightningSimpleEvent'); | |
evt.fire(); | |
}, | |
handleEvent: function (component, event, helper) { | |
console.log('event received by application: ' + component.getGlobalId()); | |
} | |
}) |
This file contains hidden or 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:event type="APPLICATION" description="Event template"> | |
<aura:attribute name="message" type="String" /> | |
</aura:event> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment