SlideShare a Scribd company logo
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
Lightning chess
Go to Developer User Groups!
Belgium: http://bit.ly/1Xqlu5p
The Netherlands: http://bit.ly/1Sbdzuo
thank y uQuestions?
thank y u
Ad

More Related Content

What's hot (20)

Winter '16 Release - Overview and Highlights
Winter '16 Release - Overview and HighlightsWinter '16 Release - Overview and Highlights
Winter '16 Release - Overview and Highlights
Salesforce Developers
 
Dreamwares salesforce (Updated)
Dreamwares salesforce (Updated)Dreamwares salesforce (Updated)
Dreamwares salesforce (Updated)
Amit Ahuja
 
Using Apex for REST Integration
Using Apex for REST IntegrationUsing Apex for REST Integration
Using Apex for REST Integration
Salesforce Developers
 
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 1
Salesforce Developers
 
Introduction to the Wave Platform API
Introduction to the Wave Platform APIIntroduction to the Wave Platform API
Introduction to the Wave Platform API
Salesforce Developers
 
Lightning Components Workshop
Lightning Components WorkshopLightning Components Workshop
Lightning Components Workshop
Salesforce Developers
 
Salesforce Lightning Experience Overview by Brainiate
Salesforce Lightning Experience Overview by BrainiateSalesforce Lightning Experience Overview by Brainiate
Salesforce Lightning Experience Overview by Brainiate
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 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
Roy 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 Components
Salesforce 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 Dive
Salesforce 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 Salesforce1
Salesforce 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 2
Salesforce Developers
 
Lightning Experience with Visualforce Best Practices
Lightning Experience with Visualforce Best PracticesLightning Experience with Visualforce Best Practices
Lightning Experience with Visualforce Best Practices
Salesforce Developers
 
Salesforce Field Service Lightning
Salesforce Field Service LightningSalesforce Field Service Lightning
Salesforce Field Service Lightning
Jayant Jindal
 
Spring '16 Release Preview Webinar
Spring '16 Release Preview Webinar Spring '16 Release Preview Webinar
Spring '16 Release Preview Webinar
Salesforce Developers
 
Coding in the App Cloud
Coding in the App CloudCoding in the App Cloud
Coding in the App Cloud
Salesforce Developers
 
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
Salesforce Developers
 
Dreamforce Developer Recap
Dreamforce Developer RecapDreamforce Developer Recap
Dreamforce Developer Recap
Salesforce Developers
 
Winter '16 Release - Overview and Highlights
Winter '16 Release - Overview and HighlightsWinter '16 Release - Overview and Highlights
Winter '16 Release - Overview and Highlights
Salesforce 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 1
Salesforce Developers
 
Introduction to the Wave Platform API
Introduction to the Wave Platform APIIntroduction to the Wave Platform API
Introduction to the Wave Platform API
Salesforce Developers
 
Salesforce Lightning Experience Overview by Brainiate
Salesforce Lightning Experience Overview by BrainiateSalesforce Lightning Experience Overview by Brainiate
Salesforce Lightning Experience Overview by Brainiate
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 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
Roy 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 Components
Salesforce 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 Dive
Salesforce 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 Salesforce1
Salesforce 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 2
Salesforce Developers
 
Lightning Experience with Visualforce Best Practices
Lightning Experience with Visualforce Best PracticesLightning Experience with Visualforce Best Practices
Lightning Experience with Visualforce Best Practices
Salesforce Developers
 
Salesforce Field Service Lightning
Salesforce Field Service LightningSalesforce Field Service Lightning
Salesforce Field Service Lightning
Jayant 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 Introduction
Salesforce Developers
 

Viewers also liked (18)

Custom Metadata Data Types
Custom Metadata Data TypesCustom Metadata Data Types
Custom Metadata Data Types
Samuel 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 2016
Samuel 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 path
Lieven Juwet
 
A Taste of Lightning in Action
A Taste of Lightning in ActionA Taste of Lightning in Action
A Taste of Lightning in Action
Steven 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 2015
Samuel De Rycke
 
ABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - PresentationABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - Presentation
Julie Minner
 
Disco duro
Disco duroDisco duro
Disco duro
Efrain Falcón Quispe
 
CV_RobinsonJunker
CV_RobinsonJunkerCV_RobinsonJunker
CV_RobinsonJunker
Amy Robinson-Junker
 
강연 Ppt
강연 Ppt강연 Ppt
강연 Ppt
필립 이
 
CV - M. Taj Arain
CV - M. Taj ArainCV - M. Taj Arain
CV - M. Taj Arain
Muhammad Taj Arain
 
Presentación gerencia en hsl
Presentación gerencia en hslPresentación gerencia en hsl
Presentación gerencia en hsl
Ana Malvacias
 
AdsBridge Tracking Software
AdsBridge Tracking SoftwareAdsBridge Tracking Software
AdsBridge Tracking Software
Alex Omelianovych
 
Gil antonio presentacion_competic 2
Gil antonio presentacion_competic 2Gil antonio presentacion_competic 2
Gil antonio presentacion_competic 2
13mama13
 
SUDHIR_-_CV -Latest
SUDHIR_-_CV -LatestSUDHIR_-_CV -Latest
SUDHIR_-_CV -Latest
SUDHIR SHIRGURKAR
 
Tamylily
TamylilyTamylily
Tamylily
lily gomez
 
20160412木桐讀書會分享 灣生回家 by Jason
20160412木桐讀書會分享 灣生回家 by Jason20160412木桐讀書會分享 灣生回家 by Jason
20160412木桐讀書會分享 灣生回家 by Jason
Librarian Mouton
 
Final report
Final reportFinal report
Final report
Moses Sabao
 
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
 
Custom Metadata Data Types
Custom Metadata Data TypesCustom Metadata Data Types
Custom Metadata Data Types
Samuel 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 2016
Samuel 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 path
Lieven Juwet
 
A Taste of Lightning in Action
A Taste of Lightning in ActionA Taste of Lightning in Action
A Taste of Lightning in Action
Steven 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 2015
Samuel De Rycke
 
ABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - PresentationABSI & ASP Summer Party 2016 - Presentation
ABSI & ASP Summer Party 2016 - Presentation
Julie Minner
 
Presentación gerencia en hsl
Presentación gerencia en hslPresentación gerencia en hsl
Presentación gerencia en hsl
Ana Malvacias
 
Gil antonio presentacion_competic 2
Gil antonio presentacion_competic 2Gil antonio presentacion_competic 2
Gil antonio presentacion_competic 2
13mama13
 
20160412木桐讀書會分享 灣生回家 by Jason
20160412木桐讀書會分享 灣生回家 by Jason20160412木桐讀書會分享 灣生回家 by Jason
20160412木桐讀書會分享 灣生回家 by Jason
Librarian 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
 
Ad

Similar to Lightning chess (20)

Introduction to A-Frame
Introduction to A-FrameIntroduction to A-Frame
Introduction to A-Frame
Daosheng Mu
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
Jussi Pohjolainen
 
Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
Damien Krotkine
 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java Developers
Yakov Fain
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOS
fpatton
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
Dmitry Vinnik
 
Actors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesActors or Not: Async Event Architectures
Actors or Not: Async Event Architectures
Yaroslav Tkachenko
 
Node.js
Node.jsNode.js
Node.js
Ian Oxley
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developers
Yakov Fain
 
Introduction to Angular JS
Introduction to Angular JSIntroduction to Angular JS
Introduction to Angular JS
Santhosh Kumar Srinivasan
 
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 5
Billie Berzinskas
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOS
jimmyatmedium
 
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-Functions
BizTalk360
 
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
Bram 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 2017
Lucas Jellema
 
Introduction to A-Frame
Introduction to A-FrameIntroduction to A-Frame
Introduction to A-Frame
Daosheng Mu
 
Angular 4 for Java Developers
Angular 4 for Java DevelopersAngular 4 for Java Developers
Angular 4 for Java Developers
Yakov Fain
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOS
fpatton
 
Developing Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptxDeveloping Lightning Components for Communities.pptx
Developing Lightning Components for Communities.pptx
Dmitry Vinnik
 
Actors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesActors or Not: Async Event Architectures
Actors or Not: Async Event Architectures
Yaroslav Tkachenko
 
Writing robust Node.js applications
Writing robust Node.js applicationsWriting robust Node.js applications
Writing robust Node.js applications
Tom Croucher
 
Angular2 Development for Java developers
Angular2 Development for Java developersAngular2 Development for Java developers
Angular2 Development for Java developers
Yakov 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 5
Billie Berzinskas
 
Medium TechTalk — iOS
Medium TechTalk — iOSMedium TechTalk — iOS
Medium TechTalk — iOS
jimmyatmedium
 
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-Functions
BizTalk360
 
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
Bram 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 2017
Lucas Jellema
 
Ad

Recently uploaded (20)

How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...
Aqusag Technologies
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptxIncreasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Increasing Retail Store Efficiency How can Planograms Save Time and Money.pptx
Anoop Ashok
 
Heap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and DeletionHeap, Types of Heap, Insertion and Deletion
Heap, Types of Heap, Insertion and Deletion
Jaydeep Kale
 
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
IEDM 2024 Tutorial2_Advances in CMOS Technologies and Future Directions for C...
organizerofv
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
TrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business ConsultingTrsLabs - Fintech Product & Business Consulting
TrsLabs - Fintech Product & Business Consulting
Trs Labs
 
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything – Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
 
Cyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of securityCyber Awareness overview for 2025 month of security
Cyber Awareness overview for 2025 month of security
riccardosl1
 
HCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser EnvironmentsHCL Nomad Web – Best Practices and Managing Multiuser Environments
HCL Nomad Web – Best Practices and Managing Multiuser Environments
panagenda
 

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
  • 33. Go to Developer User Groups! Belgium: http://bit.ly/1Xqlu5p The Netherlands: http://bit.ly/1Sbdzuo