Last active
December 30, 2018 06:23
-
-
Save douglascayers/99f891420e0726c1e835c30ad56bb65d to your computer and use it in GitHub Desktop.
Sharing JavaScript Code Using Shared Objects, https://douglascayers.com/2018/12/29/sharing-javascript-code-in-lightning-aura-components-and-freezing-javascript-prototypes/
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
<!-- YourComponent.cmp --> | |
<aura:component> | |
<ltng:require scripts="{!$Resource.SharedLibrary}" | |
afterScriptsLoaded="{!c.getSum}"/> | |
</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
/* YourComponentController.js */ | |
({ | |
getSum: function(component, event, helper) { | |
let sum = window.sum(2, 3); // use shared function on `window` object | |
console.log(sum); // 5 | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment