Last active
July 30, 2018 09:11
-
-
Save pchittum/548020cb6cb291b161dc61f9ef58c20e to your computer and use it in GitHub Desktop.
Test for singleton helper in Lightning 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
Initialized compProperty value in 3:0 to 1 | |
Initialized helperProperty value in 3:0 to 1 | |
Initialized compProperty value in 5:0 to 1 | |
Incremented helperProperty value in 5:0 to 2 | |
Initialized compProperty value in 7:0 to 1 | |
Incremented helperProperty value in 7:0 to 3 | |
Initialized compProperty value in 9:0 to 1 | |
Incremented helperProperty value in 9:0 to 4 | |
Initialized compProperty value in 11:0 to 1 | |
Incremented helperProperty value in 11:0 to 5 |
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 > | |
<aura:handler name="init" value="{!this}" action="{!c.doInit}" /> | |
</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
<aura:application access="GLOBAL" > | |
<c:TestSingletonHelper /> | |
<c:TestSingletonHelper /> | |
<c:TestSingletonHelper /> | |
<c:TestSingletonHelper /> | |
<c:TestSingletonHelper /> | |
</aura:application> |
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
({ | |
doInit : function(component, event, helper) { | |
let id = component.getGlobalId(); | |
if (!component.compProperty){ | |
component.compProperty = 1; | |
console.log("Initialized compProperty value in " + id + " to 1"); | |
} else { | |
component.compProperty += 1; | |
console.log("Incremented compProperty value in " + id + " to " + helper.helperProperty); | |
} | |
if (!helper.helperProperty) { | |
helper.helperProperty = 1; | |
console.log("Initialized helperProperty value in " + id + " to 1 "); | |
} else { | |
helper.helperProperty += 1; | |
console.log("Incremented helperProperty value in " + id + " to " + helper.helperProperty); | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment