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