SlideShare une entreprise Scribd logo
1  sur  35
Code your own Lightning
Components
Including Lightning Chess
Amsterdam World Tour - April 14th 2016
Lieven Juwet
• Developer @ ABSI
• @LievenJuwet
Samuel De Rycke
• Technical Solution Architect @ ABSI
• Salesforce MVP
• Co-Leader BE User Group
• @SamuelDeRycke
#SalesforceDevs
#SalesforceTour
#Lightning
Agenda
• Chess demo
• Lightning component framework
• Lightning components
• Communication between components
• Calling Apex
Demo: Lightning Chess
Lightning Component Framework
• Javascript/HTML5/CSS3 client
• Databinding & UI Rendering
• Stateful client & Stateless server
• Improved performance
• Component Encapsulation
• Event-driven approach
Lightning Component Framework
● Lightning Application
● Lightning Component
● Lightning Event
Lightning Component
• A Component bundle can contain multiple elements
• Component: UI Markup
• Controller
• Helper
• Style
• Renderer
Component Bundle
With each component comes its own responsibility!
Component Controller HelperStyle
Renderer
Apex
Controller
Chess Components
• Main_Game_Component
• Manage any type of game.
• Chessboard_Component
• Manage the state of the chessboard by handling location and streaming events + chess logic
• Chessboard_Location_Component
• Handle action events and render the correct state of his location.
• Player_List_Component
• Manage and display the online players and issue challenges.
• Challenge_List_Component
• Manage incoming challenges
• Streaming_API_Component
• Subscribe to PushTopics and convert streaming events into lightning events
Lightning Component
Chessboard Component markup
<!-- Chessboard Component -->
<aura:component controller='ChessGameController' extends="c:Abstract_Game" >
<!-- Set Attributes -->
<aura:attribute type="Array" name="locations"></aura:attribute>
<!-- Set Event Listeners -->
<aura:handler event="c:StreamingEvent" action="{!c.handleStreamingEvent}"/>
<aura:handler event="c:Promotion_Complete" action="{!c.handlePromotion}"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<!-- Set Event thrown -->
<aura:registerEvent name="LocationAction" type="c:LocationAction"/>
<aura:iteration var="row" items="{!v.locations}">
<aura:iteration var="location" items="{!row}">
<c:ChessBoardLocation location="{!location}" click="{!c.handleLocationClick}" />
</aura:iteration>
</aura:iteration>
</aura:component>
Lightning Component
• Declare the attribute components
• Attribute values are stored on the value provider (v)
• Access and set the values in Javascript
• Set by parent components
• Define access: Global, Public, Private
• Use them to bind your data to HTML/Components
Component Attributes
<aura:attribute name=”locations” type=”Array”></aura:attribute>
<aura:iteration var="row" items="{!v.locations}">
Lightning Component
• Locations updated by issuing component.set(‘v.locations’,newLocations)
• Re-render both iterations
• 64 new components created each time
• Move render responsibility from a central point for many components (heavy) to components
individually.
Component rendering/re-rendering
<aura:iteration var="row" items="{!v.locations}">
<aura:iteration var="location" items="{!row}">
<c:ChessBoardLocation location="{!location}" click="{!c.handleLocationClick}" />
</aura:iteration>
</aura:iteration>
Lightning Chess: Event driven approach
<!-- Chessboard Component -->
<aura:component controller='ChessGameController' extends="c:Abstract_Game" >
...
<!-- Set Event Listeners -->
<aura:handler event="c:StreamingEvent" action="{!c.handleStreamingEvent}"/>
<aura:handler event="c:Promotion_Complete" action="{!c.handlePromotion}"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<!-- Set Event thrown -->
<aura:registerEvent name="LocationAction" type="c:LocationAction"/>
...
</aura:component>
Lightning Chess: Component Communication
Chessboard
Chessboard Location
x64
Location Clicked
Location Action
Chess Logic
Event driven approach: Benefits
• Each component has its own responsibility
• Loose coupling
• Chessboard does not know who receives the event and what it does.
• Location doesn’t know the subscriber and doesn’t know what happens
• Subscribe more components to these events
• Example: Overview of fallen pieces
• Reusability of components
• Example: History of chess games
Component Controller
Component Controller
• Contains Javascript functions
• Bind controller functions in the component markup
• Access component attributes in the controller
Component Controller
• Contains the Javascript functions
• Bind controller functions in the component markup
• Access component attributes in the controller
<div … onclick=”{!c.handleLocationClick}”>
…
</div>
Component Controller
• Obtain and update component attribute values
• Send out new events
• Make a server call
handleLocationClick : function(cmp,event,helper){
var location = cmp.get(‘v.location’);
var e = cmp.getEvent(‘click’);
e.setParams({‘location’ : location});
e.fire();
}
Communication with Events
2 types of events
• Component event
• Parent component can register a handler function directly
• Send upwards in the component hierarchy through event bubbling
• Application Event
• Functions as a broadcast.
• All components in the application can register a handler
Component Event <aura:event type="COMPONENT">
<aura:attribute name="location" type="Object" />
</aura:event>
<aura:registerEvent name="click" type="c:ChessboardLocationClicked"/>
var e = cmp.getEvent('click'); e.setParams({'location':location}); e.fire();
<aura:handler name="click" event="c:ChessboardLocationClicked" action="{!c.handleLocationClick}"/>
<c:ChessBoardLocation location="{!location}" click="{!c.handleLocationClick}" />
Application Event <aura:event type="APPLICATION">
<aura:attribute name="payload" type="Object"/>
<aura:attribute name="actionType" type="String"/>
</aura:event>
<aura:registerEvent name="LocationAction" type="c:LocationAction"/>
var e = $A.get('e.c:LocationAction');
e.setParams({'payload':{'locations':possibleLocations},'actionType':'setSelectable'});
e.fire();
<aura:handler event="c:LocationAction" action="{!c.handleActionEvent}"/>
Component Helper: sharing functionality
• Each component can have helper functions
• Contains functions that are used on multiple locations in the controller
• Avoid duplicate code!
Component Controller Helper
Component style
• Component CSS is encapsulated
Component Controller HelperStyle
Component style
Component renderer
Perform your DOM manipulations in the render/re-render functions
Component Controller HelperStyle
Renderer
Component renderer
Calling Apex
Component Controller HelperStyle
Renderer Apex Controller
Calling Apex
Use AuraEnabled methods retrieve/send data to the server
Link the APEX controller to the component
public class ChessboardController{
@AuraEnabled
public static Object getBoardPieces(Id game) {
return [select Active__c,Piece_Color__c, … from ChessPiece__c where
Chessboard__c = :game];
}
}
<aura:component controller=”ChessboardController”> … </aura:component>
Calling Apex
var action = cmp.get(‘c.getBoardPieces’);
action.setParams( {‘game’:chessboard.Id});
action.setCallback(this,function(response)
{
if(!cmp.isValid())
return
if(response.getState() == ‘SUCCESS’)
{
//Handle the response
}
}
$A.enqueueAction(action);
if
Overview
• Chess demo
• Lightning component framework
• Lightning components
• Communication between components
• Calling Apex
Go to Developer User Groups!
Belgium: http://bit.ly/1Xqlu5p
The Netherlands: http://bit.ly/1Sbdzuo
thank y uQuestions?
thank y u

Contenu connexe

Tendances

Winter '16 Release - Overview and Highlights
Winter '16 Release - Overview and HighlightsWinter '16 Release - Overview and Highlights
Winter '16 Release - Overview and HighlightsSalesforce Developers
 
Dreamwares salesforce (Updated)
Dreamwares salesforce (Updated)Dreamwares salesforce (Updated)
Dreamwares salesforce (Updated)Amit Ahuja
 
Summer '15 Release Preview: Platform Feature Highlights
Summer '15 Release Preview: Platform Feature Highlights Summer '15 Release Preview: Platform Feature Highlights
Summer '15 Release Preview: Platform Feature Highlights Salesforce Developers
 
Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Salesforce Developers
 
Introduction to the Wave Platform API
Introduction to the Wave Platform APIIntroduction to the Wave Platform API
Introduction to the Wave Platform APISalesforce Developers
 
Salesforce Lightning Experience Overview by Brainiate
Salesforce Lightning Experience Overview by BrainiateSalesforce Lightning Experience Overview by Brainiate
Salesforce Lightning Experience Overview by Brainiatebrainiate
 
Lightning Design System and Components for Visualforce Developers
Lightning Design System and Components for Visualforce DevelopersLightning Design System and Components for Visualforce Developers
Lightning Design System and Components for Visualforce DevelopersSalesforce Developers
 
Salesforce Lightning component framework from 0 to app
Salesforce Lightning component framework from 0 to appSalesforce Lightning component framework from 0 to app
Salesforce Lightning component framework from 0 to appRoy Gilad
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base ComponentsSalesforce Developers
 
Salesforce.com API Series: Service Cloud Console Deep Dive
Salesforce.com API Series: Service Cloud Console Deep DiveSalesforce.com API Series: Service Cloud Console Deep Dive
Salesforce.com API Series: Service Cloud Console Deep DiveSalesforce Developers
 
Easy REST Integrations with Lightning Components and Salesforce1
Easy REST Integrations with Lightning Components and Salesforce1Easy REST Integrations with Lightning Components and Salesforce1
Easy REST Integrations with Lightning Components and Salesforce1Salesforce Developers
 
Secure Development on the Salesforce Platform - Part 2
Secure Development on the Salesforce Platform - Part 2Secure Development on the Salesforce Platform - Part 2
Secure Development on the Salesforce Platform - Part 2Salesforce Developers
 
Lightning Experience with Visualforce Best Practices
Lightning Experience with Visualforce Best PracticesLightning Experience with Visualforce Best Practices
Lightning Experience with Visualforce Best PracticesSalesforce Developers
 
Salesforce Field Service Lightning
Salesforce Field Service LightningSalesforce Field Service Lightning
Salesforce Field Service LightningJayant Jindal
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionSalesforce Developers
 

Tendances (20)

Winter '16 Release - Overview and Highlights
Winter '16 Release - Overview and HighlightsWinter '16 Release - Overview and Highlights
Winter '16 Release - Overview and Highlights
 
Dreamwares salesforce (Updated)
Dreamwares salesforce (Updated)Dreamwares salesforce (Updated)
Dreamwares salesforce (Updated)
 
Using Apex for REST Integration
Using Apex for REST IntegrationUsing Apex for REST Integration
Using Apex for REST Integration
 
Summer '15 Release Preview: Platform Feature Highlights
Summer '15 Release Preview: Platform Feature Highlights Summer '15 Release Preview: Platform Feature Highlights
Summer '15 Release Preview: Platform Feature Highlights
 
Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1Mastering the Lightning Framework - Part 1
Mastering the Lightning Framework - Part 1
 
Introduction to the Wave Platform API
Introduction to the Wave Platform APIIntroduction to the Wave Platform API
Introduction to the Wave Platform API
 
Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
 
Salesforce Lightning Experience Overview by Brainiate
Salesforce Lightning Experience Overview by BrainiateSalesforce Lightning Experience Overview by Brainiate
Salesforce Lightning Experience Overview by Brainiate
 
Lightning Design System and Components for Visualforce Developers
Lightning Design System and Components for Visualforce DevelopersLightning Design System and Components for Visualforce Developers
Lightning Design System and Components for Visualforce Developers
 
Salesforce Lightning component framework from 0 to app
Salesforce Lightning component framework from 0 to appSalesforce Lightning component framework from 0 to app
Salesforce Lightning component framework from 0 to app
 
Local development with Open Source Base Components
Local development with Open Source Base ComponentsLocal development with Open Source Base Components
Local development with Open Source Base Components
 
Salesforce.com API Series: Service Cloud Console Deep Dive
Salesforce.com API Series: Service Cloud Console Deep DiveSalesforce.com API Series: Service Cloud Console Deep Dive
Salesforce.com API Series: Service Cloud Console Deep Dive
 
Easy REST Integrations with Lightning Components and Salesforce1
Easy REST Integrations with Lightning Components and Salesforce1Easy REST Integrations with Lightning Components and Salesforce1
Easy REST Integrations with Lightning Components and Salesforce1
 
Secure Development on the Salesforce Platform - Part 2
Secure Development on the Salesforce Platform - Part 2Secure Development on the Salesforce Platform - Part 2
Secure Development on the Salesforce Platform - Part 2
 
Lightning Experience with Visualforce Best Practices
Lightning Experience with Visualforce Best PracticesLightning Experience with Visualforce Best Practices
Lightning Experience with Visualforce Best Practices
 
Salesforce Field Service Lightning
Salesforce Field Service LightningSalesforce Field Service Lightning
Salesforce Field Service Lightning
 
Spring '16 Release Preview Webinar
Spring '16 Release Preview Webinar Spring '16 Release Preview Webinar
Spring '16 Release Preview Webinar
 
Coding in the App Cloud
Coding in the App CloudCoding in the App Cloud
Coding in the App Cloud
 
Lightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An IntroductionLightning web components - Episode 1 - An Introduction
Lightning web components - Episode 1 - An Introduction
 
Dreamforce Developer Recap
Dreamforce Developer RecapDreamforce Developer Recap
Dreamforce Developer Recap
 

En vedette

Custom Metadata Data Types
Custom Metadata Data TypesCustom Metadata Data Types
Custom Metadata Data TypesSamuel Moyson
 
Integration with the Salesforce App Cloud - Amsterdam 2016
Integration with the Salesforce App Cloud - Amsterdam 2016Integration with the Salesforce App Cloud - Amsterdam 2016
Integration with the Salesforce App Cloud - Amsterdam 2016Samuel De Rycke
 
Salesforce World Tour Amsterdam: Guide your users through a process using path
Salesforce World Tour Amsterdam:  Guide your users through a process using pathSalesforce World Tour Amsterdam:  Guide your users through a process using path
Salesforce World Tour Amsterdam: Guide your users through a process using pathLieven Juwet
 
A Taste of Lightning in Action
A Taste of Lightning in ActionA Taste of Lightning in Action
A Taste of Lightning in ActionSteven Hugo
 
Asynchronous Apex Salesforce World Tour Paris 2015
Asynchronous Apex Salesforce World Tour Paris 2015Asynchronous Apex Salesforce World Tour Paris 2015
Asynchronous Apex Salesforce World Tour Paris 2015Samuel De Rycke
 
ABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - PresentationABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - PresentationJulie Minner
 
Presentación gerencia en hsl
Presentación gerencia en hslPresentación gerencia en hsl
Presentación gerencia en hslAna Malvacias
 
Gil antonio presentacion_competic 2
Gil antonio presentacion_competic 2Gil antonio presentacion_competic 2
Gil antonio presentacion_competic 213mama13
 
20160412木桐讀書會分享 灣生回家 by Jason
20160412木桐讀書會分享 灣生回家 by Jason20160412木桐讀書會分享 灣生回家 by Jason
20160412木桐讀書會分享 灣生回家 by JasonLibrarian Mouton
 
Repairs B-199 Cherry Point Air Traffic Control Supt, QCM, SSHO
Repairs B-199 Cherry Point Air Traffic Control Supt, QCM, SSHO Repairs B-199 Cherry Point Air Traffic Control Supt, QCM, SSHO
Repairs B-199 Cherry Point Air Traffic Control Supt, QCM, SSHO Richard Bush
 

En vedette (18)

Custom Metadata Data Types
Custom Metadata Data TypesCustom Metadata Data Types
Custom Metadata Data Types
 
Integration with the Salesforce App Cloud - Amsterdam 2016
Integration with the Salesforce App Cloud - Amsterdam 2016Integration with the Salesforce App Cloud - Amsterdam 2016
Integration with the Salesforce App Cloud - Amsterdam 2016
 
Salesforce World Tour Amsterdam: Guide your users through a process using path
Salesforce World Tour Amsterdam:  Guide your users through a process using pathSalesforce World Tour Amsterdam:  Guide your users through a process using path
Salesforce World Tour Amsterdam: Guide your users through a process using path
 
A Taste of Lightning in Action
A Taste of Lightning in ActionA Taste of Lightning in Action
A Taste of Lightning in Action
 
Asynchronous Apex Salesforce World Tour Paris 2015
Asynchronous Apex Salesforce World Tour Paris 2015Asynchronous Apex Salesforce World Tour Paris 2015
Asynchronous Apex Salesforce World Tour Paris 2015
 
ABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - PresentationABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - Presentation
 
Disco duro
Disco duroDisco duro
Disco duro
 
CV_RobinsonJunker
CV_RobinsonJunkerCV_RobinsonJunker
CV_RobinsonJunker
 
강연 Ppt
강연 Ppt강연 Ppt
강연 Ppt
 
CV - M. Taj Arain
CV - M. Taj ArainCV - M. Taj Arain
CV - M. Taj Arain
 
Presentación gerencia en hsl
Presentación gerencia en hslPresentación gerencia en hsl
Presentación gerencia en hsl
 
AdsBridge Tracking Software
AdsBridge Tracking SoftwareAdsBridge Tracking Software
AdsBridge Tracking Software
 
Gil antonio presentacion_competic 2
Gil antonio presentacion_competic 2Gil antonio presentacion_competic 2
Gil antonio presentacion_competic 2
 
SUDHIR_-_CV -Latest
SUDHIR_-_CV -LatestSUDHIR_-_CV -Latest
SUDHIR_-_CV -Latest
 
Tamylily
TamylilyTamylily
Tamylily
 
20160412木桐讀書會分享 灣生回家 by Jason
20160412木桐讀書會分享 灣生回家 by Jason20160412木桐讀書會分享 灣生回家 by Jason
20160412木桐讀書會分享 灣生回家 by Jason
 
Final report
Final reportFinal report
Final report
 
Repairs B-199 Cherry Point Air Traffic Control Supt, QCM, SSHO
Repairs B-199 Cherry Point Air Traffic Control Supt, QCM, SSHO Repairs B-199 Cherry Point Air Traffic Control Supt, QCM, SSHO
Repairs B-199 Cherry Point Air Traffic Control Supt, QCM, SSHO
 

Similaire à Lightning chess

Introduction to A-Frame
Introduction to A-FrameIntroduction to A-Frame
Introduction to A-FrameDaosheng Mu
 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java DevelopersYakov Fain
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOSfpatton
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDmitry Vinnik
 
Actors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesActors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesYaroslav Tkachenko
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applicationsTom Croucher
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developersYakov Fain
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Thinkful
 
5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)Christian Rokitta
 
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha
 
Coldbox developer training – session 5
Coldbox developer training – session 5Coldbox developer training – session 5
Coldbox developer training – session 5Billie Berzinskas
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOSjimmyatmedium
 
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...Matt Spradley
 
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
Integration-Monday-Stateful-Programming-Models-Serverless-FunctionsIntegration-Monday-Stateful-Programming-Models-Serverless-Functions
Integration-Monday-Stateful-Programming-Models-Serverless-FunctionsBizTalk360
 
Easy Cloud Native Transformation using HashiCorp Nomad
Easy Cloud Native Transformation using HashiCorp NomadEasy Cloud Native Transformation using HashiCorp Nomad
Easy Cloud Native Transformation using HashiCorp NomadBram Vogelaar
 
ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017Lucas Jellema
 

Similaire à Lightning chess (20)

Introduction to A-Frame
Introduction to A-FrameIntroduction to A-Frame
Introduction to A-Frame
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java Developers
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOS
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
 
Actors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesActors or Not: Async Event Architectures
Actors or Not: Async Event Architectures
 
Node.js
Node.jsNode.js
Node.js
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developers
 
Introduction to Angular JS
Introduction to Angular JSIntroduction to Angular JS
Introduction to Angular JS
 
Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)Build a game with javascript (may 21 atlanta)
Build a game with javascript (may 21 atlanta)
 
5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)5 x HTML5 worth using in APEX (5)
5 x HTML5 worth using in APEX (5)
 
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
 
Coldbox developer training – session 5
Coldbox developer training – session 5Coldbox developer training – session 5
Coldbox developer training – session 5
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOS
 
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
 
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
Integration-Monday-Stateful-Programming-Models-Serverless-FunctionsIntegration-Monday-Stateful-Programming-Models-Serverless-Functions
Integration-Monday-Stateful-Programming-Models-Serverless-Functions
 
Easy Cloud Native Transformation using HashiCorp Nomad
Easy Cloud Native Transformation using HashiCorp NomadEasy Cloud Native Transformation using HashiCorp Nomad
Easy Cloud Native Transformation using HashiCorp Nomad
 
ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017ADF and JavaScript - AMIS SIG, July 2017
ADF and JavaScript - AMIS SIG, July 2017
 

Dernier

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Lightning chess

  • 1. Code your own Lightning Components Including Lightning Chess Amsterdam World Tour - April 14th 2016
  • 2. Lieven Juwet • Developer @ ABSI • @LievenJuwet
  • 3. Samuel De Rycke • Technical Solution Architect @ ABSI • Salesforce MVP • Co-Leader BE User Group • @SamuelDeRycke
  • 5. Agenda • Chess demo • Lightning component framework • Lightning components • Communication between components • Calling Apex
  • 7. Lightning Component Framework • Javascript/HTML5/CSS3 client • Databinding & UI Rendering • Stateful client & Stateless server • Improved performance • Component Encapsulation • Event-driven approach
  • 8. Lightning Component Framework ● Lightning Application ● Lightning Component ● Lightning Event
  • 9. Lightning Component • A Component bundle can contain multiple elements • Component: UI Markup • Controller • Helper • Style • Renderer Component Bundle With each component comes its own responsibility! Component Controller HelperStyle Renderer Apex Controller
  • 10. Chess Components • Main_Game_Component • Manage any type of game. • Chessboard_Component • Manage the state of the chessboard by handling location and streaming events + chess logic • Chessboard_Location_Component • Handle action events and render the correct state of his location. • Player_List_Component • Manage and display the online players and issue challenges. • Challenge_List_Component • Manage incoming challenges • Streaming_API_Component • Subscribe to PushTopics and convert streaming events into lightning events
  • 11. Lightning Component Chessboard Component markup <!-- Chessboard Component --> <aura:component controller='ChessGameController' extends="c:Abstract_Game" > <!-- Set Attributes --> <aura:attribute type="Array" name="locations"></aura:attribute> <!-- Set Event Listeners --> <aura:handler event="c:StreamingEvent" action="{!c.handleStreamingEvent}"/> <aura:handler event="c:Promotion_Complete" action="{!c.handlePromotion}"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <!-- Set Event thrown --> <aura:registerEvent name="LocationAction" type="c:LocationAction"/> <aura:iteration var="row" items="{!v.locations}"> <aura:iteration var="location" items="{!row}"> <c:ChessBoardLocation location="{!location}" click="{!c.handleLocationClick}" /> </aura:iteration> </aura:iteration> </aura:component>
  • 12. Lightning Component • Declare the attribute components • Attribute values are stored on the value provider (v) • Access and set the values in Javascript • Set by parent components • Define access: Global, Public, Private • Use them to bind your data to HTML/Components Component Attributes <aura:attribute name=”locations” type=”Array”></aura:attribute> <aura:iteration var="row" items="{!v.locations}">
  • 13. Lightning Component • Locations updated by issuing component.set(‘v.locations’,newLocations) • Re-render both iterations • 64 new components created each time • Move render responsibility from a central point for many components (heavy) to components individually. Component rendering/re-rendering <aura:iteration var="row" items="{!v.locations}"> <aura:iteration var="location" items="{!row}"> <c:ChessBoardLocation location="{!location}" click="{!c.handleLocationClick}" /> </aura:iteration> </aura:iteration>
  • 14. Lightning Chess: Event driven approach <!-- Chessboard Component --> <aura:component controller='ChessGameController' extends="c:Abstract_Game" > ... <!-- Set Event Listeners --> <aura:handler event="c:StreamingEvent" action="{!c.handleStreamingEvent}"/> <aura:handler event="c:Promotion_Complete" action="{!c.handlePromotion}"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <!-- Set Event thrown --> <aura:registerEvent name="LocationAction" type="c:LocationAction"/> ... </aura:component>
  • 15. Lightning Chess: Component Communication Chessboard Chessboard Location x64 Location Clicked Location Action Chess Logic
  • 16. Event driven approach: Benefits • Each component has its own responsibility • Loose coupling • Chessboard does not know who receives the event and what it does. • Location doesn’t know the subscriber and doesn’t know what happens • Subscribe more components to these events • Example: Overview of fallen pieces • Reusability of components • Example: History of chess games
  • 17. Component Controller Component Controller • Contains Javascript functions • Bind controller functions in the component markup • Access component attributes in the controller
  • 18. Component Controller • Contains the Javascript functions • Bind controller functions in the component markup • Access component attributes in the controller <div … onclick=”{!c.handleLocationClick}”> … </div>
  • 19. Component Controller • Obtain and update component attribute values • Send out new events • Make a server call handleLocationClick : function(cmp,event,helper){ var location = cmp.get(‘v.location’); var e = cmp.getEvent(‘click’); e.setParams({‘location’ : location}); e.fire(); }
  • 20. Communication with Events 2 types of events • Component event • Parent component can register a handler function directly • Send upwards in the component hierarchy through event bubbling • Application Event • Functions as a broadcast. • All components in the application can register a handler
  • 21. Component Event <aura:event type="COMPONENT"> <aura:attribute name="location" type="Object" /> </aura:event> <aura:registerEvent name="click" type="c:ChessboardLocationClicked"/> var e = cmp.getEvent('click'); e.setParams({'location':location}); e.fire(); <aura:handler name="click" event="c:ChessboardLocationClicked" action="{!c.handleLocationClick}"/> <c:ChessBoardLocation location="{!location}" click="{!c.handleLocationClick}" />
  • 22. Application Event <aura:event type="APPLICATION"> <aura:attribute name="payload" type="Object"/> <aura:attribute name="actionType" type="String"/> </aura:event> <aura:registerEvent name="LocationAction" type="c:LocationAction"/> var e = $A.get('e.c:LocationAction'); e.setParams({'payload':{'locations':possibleLocations},'actionType':'setSelectable'}); e.fire(); <aura:handler event="c:LocationAction" action="{!c.handleActionEvent}"/>
  • 23. Component Helper: sharing functionality • Each component can have helper functions • Contains functions that are used on multiple locations in the controller • Avoid duplicate code! Component Controller Helper
  • 24. Component style • Component CSS is encapsulated Component Controller HelperStyle
  • 26. Component renderer Perform your DOM manipulations in the render/re-render functions Component Controller HelperStyle Renderer
  • 28. Calling Apex Component Controller HelperStyle Renderer Apex Controller
  • 29. Calling Apex Use AuraEnabled methods retrieve/send data to the server Link the APEX controller to the component public class ChessboardController{ @AuraEnabled public static Object getBoardPieces(Id game) { return [select Active__c,Piece_Color__c, … from ChessPiece__c where Chessboard__c = :game]; } } <aura:component controller=”ChessboardController”> … </aura:component>
  • 30. Calling Apex var action = cmp.get(‘c.getBoardPieces’); action.setParams( {‘game’:chessboard.Id}); action.setCallback(this,function(response) { if(!cmp.isValid()) return if(response.getState() == ‘SUCCESS’) { //Handle the response } } $A.enqueueAction(action); if
  • 31. Overview • Chess demo • Lightning component framework • Lightning components • Communication between components • Calling Apex
  • 32.
  • 33. Go to Developer User Groups! Belgium: http://bit.ly/1Xqlu5p The Netherlands: http://bit.ly/1Sbdzuo