Skip to content

Instantly share code, notes, and snippets.

@choudharymanish8585
Created September 19, 2018 23:44
Show Gist options
  • Save choudharymanish8585/00fb8e9bf904a7e7033a0ae7da3341ea to your computer and use it in GitHub Desktop.
Save choudharymanish8585/00fb8e9bf904a7e7033a0ae7da3341ea to your computer and use it in GitHub Desktop.
<aura:component access="global">
<!-- ChannelName, which needs to subscribed -->
<aura:attribute name="channelName" type="String" required="true"/>
<!-- Save the reference of current subscription, which can be unsubscribe later on -->
<aura:attribute name="subscription" type="Object"/>
<!-- This event is fired when a component is destroyed.
Handle this event if you need to do custom cleanup when a component is destroyed.-->
<aura:handler name="destroy" value="{!this}" action="{!c.unsubscribe}"/>
<!-- init event -->
<aura:handler name="init" value="{!this}" action="{!c.subscribe}"/>
<!-- empApi component which will be used to subscribe/unsubscribe to a channel -->
<lightning:empApi aura:id="empApi"/>
<!-- Component event, which will be fired once the message is received
This event will be handled by parent component to perform needful action on stream event -->
<aura:registerEvent name="onEmpEvent" type="c:EmpEvent"/>
</aura:component>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment