├── .gitignore ├── README.md ├── config └── project-scratch-def.json ├── force-app └── main │ └── default │ ├── applications │ └── Continuation.app-meta.xml │ ├── aura │ ├── ContinuationBroker │ │ ├── ContinuationBroker.cmp │ │ ├── ContinuationBroker.cmp-meta.xml │ │ └── ContinuationBrokerController.js │ ├── ContinuationBrokerDemo │ │ ├── ContinuationBrokerDemo.cmp │ │ ├── ContinuationBrokerDemo.cmp-meta.xml │ │ ├── ContinuationBrokerDemo.css │ │ └── ContinuationBrokerDemoController.js │ ├── ContinuationProxy │ │ ├── ContinuationProxy.cmp │ │ ├── ContinuationProxy.cmp-meta.xml │ │ ├── ContinuationProxyController.js │ │ └── ContinuationProxyHelper.js │ ├── ContinuationProxyDemo │ │ ├── ContinuationProxyDemo.cmp │ │ ├── ContinuationProxyDemo.cmp-meta.xml │ │ ├── ContinuationProxyDemo.css │ │ └── ContinuationProxyDemoController.js │ ├── ContinuationRequest │ │ ├── ContinuationRequest.evt │ │ └── ContinuationRequest.evt-meta.xml │ └── SimpleContinuationDemo │ │ ├── SimpleContinuationDemo.cmp │ │ ├── SimpleContinuationDemo.cmp-meta.xml │ │ ├── SimpleContinuationDemo.css │ │ └── SimpleContinuationDemoController.js │ ├── classes │ ├── ContinuationController.cls │ ├── ContinuationController.cls-meta.xml │ ├── SimpleContinuationController.cls │ └── SimpleContinuationController.cls-meta.xml │ ├── flexipages │ ├── Continuation.flexipage-meta.xml │ ├── Continuation_Examples.flexipage-meta.xml │ └── Continuation_UtilityBar.flexipage-meta.xml │ ├── pages │ ├── ContinuationProxy.page │ ├── ContinuationProxy.page-meta.xml │ ├── SimpleContinuation.page │ └── SimpleContinuation.page-meta.xml │ ├── permissionsets │ └── continuation.permissionset-meta.xml │ ├── profiles │ ├── Admin.profile-meta.xml │ ├── Custom%3A Marketing Profile.profile-meta.xml │ ├── Custom%3A Sales Profile.profile-meta.xml │ └── Custom%3A Support Profile.profile-meta.xml │ ├── remoteSiteSettings │ └── LongRunningService.remoteSite-meta.xml │ └── tabs │ ├── Continuation.tab-meta.xml │ └── Continuation_Examples.tab-meta.xml └── sfdx-project.json /.gitignore: -------------------------------------------------------------------------------- 1 | .classpath 2 | .DS_Store 3 | .sfdx 4 | .project 5 | .salesforce 6 | node_modules 7 | .idea 8 | .tern-project 9 | .settings 10 | selenium-client-jars/ 11 | test/artifacts -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Calling an Apex Continuation from a Lightning Component 2 | 3 | Read [this blog post](https://developer.salesforce.com/blogs/developer-relations/) to learn more about the examples in this repository. 4 | 5 | ## Installation Instructions 6 | 7 | 1. Authenticate with your hub org (if not already done): 8 | ``` 9 | sfdx force:auth:web:login -d -a myhuborg 10 | ``` 11 | 12 | 1. Clone the repository: 13 | ``` 14 | git clone https://github.com/ccoenraets/lightning-component-apex-continuation 15 | cd lightning-component-apex-continuation 16 | ``` 17 | 18 | 1. Create a scratch org and provide it with an alias (continuations): 19 | ``` 20 | sfdx force:org:create -s -f config/project-scratch-def.json -a continuations 21 | ``` 22 | 23 | 1. Push the app to your scratch org: 24 | ``` 25 | sfdx force:source:push 26 | ``` 27 | 28 | 1. Assign the ```continuation``` permission set to the default user: 29 | ``` 30 | sfdx force:user:permset:assign -n continuation 31 | ``` 32 | 33 | 1. Open the scratch org: 34 | ``` 35 | sfdx force:org:open 36 | ``` 37 | 38 | 1. Open the Continuation sample app in the App Launcher -------------------------------------------------------------------------------- /config/project-scratch-def.json: -------------------------------------------------------------------------------- 1 | { 2 | "orgName": "ccoenraets Company", 3 | "edition": "Developer", 4 | "orgPreferences" : { 5 | "enabled": ["S1DesktopEnabled"] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /force-app/main/default/applications/Continuation.app-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #0070D2 5 | 6 | Large 7 | 8 | Standard 9 | Continuation 10 | Continuation_Examples 11 | Lightning 12 | Continuation_UtilityBar 13 | 14 | -------------------------------------------------------------------------------- /force-app/main/default/aura/ContinuationBroker/ContinuationBroker.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /force-app/main/default/aura/ContinuationBroker/ContinuationBroker.cmp-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 40.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /force-app/main/default/aura/ContinuationBroker/ContinuationBrokerController.js: -------------------------------------------------------------------------------- 1 | ({ 2 | onContinuationRequest : function(component, event, helper) { 3 | var methodName = event.getParam("methodName"); 4 | var methodParams = event.getParam("methodParams"); 5 | methodParams = JSON.parse(JSON.stringify(methodParams)); 6 | var callback = event.getParam("callback"); 7 | component.find("proxy").invoke(methodName, methodParams, callback); 8 | } 9 | 10 | }) -------------------------------------------------------------------------------- /force-app/main/default/aura/ContinuationBrokerDemo/ContinuationBrokerDemo.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 |
16 | 17 |
18 | 19 |
-------------------------------------------------------------------------------- /force-app/main/default/aura/ContinuationBrokerDemo/ContinuationBrokerDemo.cmp-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 40.0 4 | A Lightning Component Bundle 5 | 6 | -------------------------------------------------------------------------------- /force-app/main/default/aura/ContinuationBrokerDemo/ContinuationBrokerDemo.css: -------------------------------------------------------------------------------- 1 | .THIS .slds-card__body { 2 | padding: 8px; 3 | } 4 | 5 | .THIS .slds-form-element { 6 | margin: 4px 0; 7 | } 8 | 9 | .THIS textarea { 10 | height: 150px; 11 | } 12 | 13 | .THIS button { 14 | margin-bottom: 4px; 15 | } -------------------------------------------------------------------------------- /force-app/main/default/aura/ContinuationBrokerDemo/ContinuationBrokerDemoController.js: -------------------------------------------------------------------------------- 1 | ({ 2 | getProduct : function(component, event, helper) { 3 | var productId = component.get("v.productId"); 4 | var latency = component.get("v.latency"); 5 | var request = $A.get("e.c:ContinuationRequest"); 6 | request.setParams({ 7 | methodName: "getProduct", 8 | methodParams: [productId, latency], 9 | callback: function(result) { 10 | var plainText = result.replace(/"/g, '"').replace(/'/g, "'"); 11 | component.set("v.result", plainText); 12 | } 13 | }); 14 | request.fire(); 15 | }, 16 | 17 | getProducts : function(component, event, helper) { 18 | var latency = component.get("v.latency"); 19 | var request = $A.get("e.c:ContinuationRequest"); 20 | request.setParams({ 21 | methodName: "getProducts", 22 | methodParams: [latency], 23 | callback: function(result) { 24 | var plainText = result.replace(/"/g, '"').replace(/'/g, "'"); 25 | component.set("v.result", plainText); 26 | } 27 | }); 28 | request.fire(); 29 | }, 30 | 31 | }) -------------------------------------------------------------------------------- /force-app/main/default/aura/ContinuationProxy/ContinuationProxy.cmp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |