• Jason Sippie
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
I'm having an issue with Spring '07 Lightning Application Events. It seems that handlers of an application event are being notified multiple times for a single firing of the event. This can be replicated on various browsers. 

How to reproduce the error:
1) Create the below components and put them in a new lightning page for an object of your choice. 
2) Assign that page to a profile, app or org
3) Navigate to that object's list view and then drill down to the newly created page
4) Press the button. The console should show this:
Test2 receiving event
Test1 receiving event

5) Navigate back to the list view and drill down on another record
6) Press the button. The console should show this:
Test2 receiving event
Test1 receiving event
Test2 receiving event
Test1 receiving event

7) If you repeat steps 5 and 6, you will get an additional two lines in the console for each time you repeat the process. I.e., one firing of the event is causing the handlers to be notified multiple times. 

Incidentally, I don't have this problem in the community edition. It's only in the base lightning experience version that it crops up. Can anyone replicate this? Thanks. 

Component #1
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:handler event="c:pvStateControlEvt" action="{!c.receiveEvent}"  phase="default" />
    <aura:registerEvent name="stateControlEvent" type="c:pvStateControlEvt"/>

I send and receive events
            <lightning:button label="sendEvent" aura:id="testButton" onclick="{!c.fireEvent}"/>

</aura:component>

Component #1 controller
({
fireEvent : function(component, event, helper) {
       var theEvent = $A.get("e.c:pvStateControlEvt");
        theEvent.fire();

},
receiveEvent : function(component, event, helper) {
        console.log("Test1 receiving event");
    }
})


Component #2
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:handler event="c:pvStateControlEvt" action="{!c.receiveEvent}"  phase="default" />
    I receive events
</aura:component>

Component #2 controller
({
receiveEvent : function(component, event, helper) {
        console.log("Test2 receiving event");
    }
})

Event pvStateControlEvt
 
<aura:event type="APPLICATION" description="My event" >
        <aura:attribute name="myAttribute" type="String"/>
</aura:event>

 
I'm having an issue with Spring '07 Lightning Application Events. It seems that handlers of an application event are being notified multiple times for a single firing of the event. This can be replicated on various browsers. 

How to reproduce the error:
1) Create the below components and put them in a new lightning page for an object of your choice. 
2) Assign that page to a profile, app or org
3) Navigate to that object's list view and then drill down to the newly created page
4) Press the button. The console should show this:
Test2 receiving event
Test1 receiving event

5) Navigate back to the list view and drill down on another record
6) Press the button. The console should show this:
Test2 receiving event
Test1 receiving event
Test2 receiving event
Test1 receiving event

7) If you repeat steps 5 and 6, you will get an additional two lines in the console for each time you repeat the process. I.e., one firing of the event is causing the handlers to be notified multiple times. 

Incidentally, I don't have this problem in the community edition. It's only in the base lightning experience version that it crops up. Can anyone replicate this? Thanks. 

Component #1
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:handler event="c:pvStateControlEvt" action="{!c.receiveEvent}"  phase="default" />
    <aura:registerEvent name="stateControlEvent" type="c:pvStateControlEvt"/>

I send and receive events
            <lightning:button label="sendEvent" aura:id="testButton" onclick="{!c.fireEvent}"/>

</aura:component>

Component #1 controller
({
fireEvent : function(component, event, helper) {
       var theEvent = $A.get("e.c:pvStateControlEvt");
        theEvent.fire();

},
receiveEvent : function(component, event, helper) {
        console.log("Test1 receiving event");
    }
})


Component #2
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
<aura:handler event="c:pvStateControlEvt" action="{!c.receiveEvent}"  phase="default" />
    I receive events
</aura:component>

Component #2 controller
({
receiveEvent : function(component, event, helper) {
        console.log("Test2 receiving event");
    }
})

Event pvStateControlEvt
 
<aura:event type="APPLICATION" description="My event" >
        <aura:attribute name="myAttribute" type="String"/>
</aura:event>