all aboard the lightning components action service
TRANSCRIPT
![Page 1: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/1.jpg)
All Aboard The Lightning Components Action Service
Peter Chittum Developer Evangelist @pchittum github.com/pchittum
![Page 2: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/2.jpg)
Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
![Page 3: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/3.jpg)
Peter Chittum Developer Evangelist @pchittum github.com/pchittum
Speaker
![Page 4: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/4.jpg)
Agenda
▪ Brief Overview of Components ▪ Action Service Basics ▪ Beyond the Basics ▪ A Miscellany of Things
![Page 5: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/5.jpg)
App Cloud and Lightning
Connect Process Builder
App Builder
Component Framework
![Page 6: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/6.jpg)
Introducing Lightning Components Reusable UI components for any device
Connect Process Builder
App Builder
Component Framework
![Page 7: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/7.jpg)
Component Artifacts
Design Principles
• Structured Bundle of Resources
• Client-side Rendered
• Extensible, Reusable, Atomic, Event-Driven
• Apex as backend
• First Class UI Citizen APP or COMPONENT BUNDLE
Definition: markup
Style: css
Helper : js
Documentation
Controller: js
Renderer: js
Design Markup Icon: SVG
![Page 8: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/8.jpg)
Component Client Side Rendering
JSON
component:{...}
<div>...</div>
![Page 9: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/9.jpg)
Component State
Attribute
![Page 10: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/10.jpg)
Component-to-Component Communication
Event
![Page 11: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/11.jpg)
Component-to-Server Communication
Action
![Page 12: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/12.jpg)
Agenda
▪ Brief Overview of Components ▪ Action Service Basics ▪ Beyond the Basics ▪ A Miscellany of Things
![Page 13: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/13.jpg)
Actions: Interact with the Server
• Apex Method Surfaced to Lightning Components • @AuraEnabled annotation
![Page 14: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/14.jpg)
Many Components Many Server Trips
XMLHttpRequest
XMLHttpRequest
XMLHttpRequest
![Page 15: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/15.jpg)
Many Components Many Actions: Boxcarring
Action S
ervice
![Page 16: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/16.jpg)
Demo
![Page 17: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/17.jpg)
Agenda
▪ Brief Overview of Components ▪ Action Service Basics ▪ Beyond the Basics ▪ A Miscellany of Things
![Page 18: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/18.jpg)
Defer High Volume Actions
Action S
ervice
• Defer High-Volume Actions • Action.setCaboose()
![Page 19: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/19.jpg)
Insert tracking record
Caboose action measures on
setInterval
Device Orientation
Stop tracking Update record Clear handlers
Component render
wobble__c measurement__c
Demo
![Page 20: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/20.jpg)
Parent Child Display Optimization
1
2
![Page 21: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/21.jpg)
Actions: Chained
callback enqueueAction(child)
![Page 22: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/22.jpg)
Demo
![Page 23: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/23.jpg)
Agenda
▪ Brief Overview of Components ▪ Action Service Basics ▪ Beyond the Basics ▪ A Miscellany of Things
![Page 24: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/24.jpg)
Useful Tools and Lessons
• Javascript
• Callbacks and isValid
• Closures
• Unsupported Events
• Only on init
• Component Lifecycle
![Page 25: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/25.jpg)
Learn Javascript
James Governor, RedMonk
![Page 26: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/26.jpg)
Javascript is Async
console.log('this will go first’); setTimeout(function(){'this happens third'},1); console.log('this happens second');
// output: 'this will go first' 'this happens second' 'this happens third'
1 2 3 4 5 6 7 8
![Page 27: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/27.jpg)
Check Component Validity: isValid() myhandler : function(component, event, helper){ ... var action = component.get('c.myApexMethod'); ... action.setCallback(this, function(serverResponse){ ... component.set('v.myAttrib',serverResponse.getReturnValue()); }); $A.enqueueAction(action);
1 2 3 4 5 6 7 8 9
action.setCallback(this, (function(serverResponse){ ... if (component.isValid()) {
component.set('v.myAttrib',serverResponse.getReturnValue()); } else { ...exit gracefully } });
1 2 3 4 5 6 7 8 9
![Page 28: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/28.jpg)
Closures for Reusability
//in MyComponentHelper.js callbackFactory : function(component){ return function (serverResponse){ component.set('v.myAttribute', serverResponse.getReturnValue()); } }
1 2 3 4 5 6 7
doInit: function(component, event, helper){ component.myCallbackFunction = helper.callbackFactory(component); });
1 2 3
//while setting up action do this... action.setCallback(this, helper.myCallbackFunction);
1 2
![Page 29: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/29.jpg)
Clean Up After Yourself in Unrender
unrender: function(component, helper){ window.removeEventListener('deviceorientation',component.doOrientation);
}
1 2 3 4 5 6 7 8 9
![Page 30: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/30.jpg)
Go Play and Break Things That what your Developer Edition org is for!
• Action Service is how your Lightning Component talks to the App Cloud
• Learn it!
• It is still new, so learn the effects of working with it
• http://salesforce.stackexchange.com
![Page 31: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/31.jpg)
Q & A
Peter Chittum Developer Evangelist @pchittum github.com/pchittum
A list of resources will be posted to the session Chatter feed.
![Page 32: All Aboard the Lightning Components Action Service](https://reader034.vdocuments.us/reader034/viewer/2022042619/58f37c801a28abca498b459f/html5/thumbnails/32.jpg)
Thank you