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
Go to Developer User Groups!
Belgium: http://bit.ly/1Xqlu5p
The Netherlands: http://bit.ly/1Sbdzuo
thank y uQuestions?
thank y u

More Related Content

What's hot

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
 

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
 
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
 

Viewers also liked

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
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
 

Viewers also liked (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
 

Similar to Lightning chess

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
 

Similar to 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
 

Recently uploaded

Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
Jakub Marek
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
operationspcvita
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
Brandon Minnick, MBA
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
Fwdays
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
ScyllaDB
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
akankshawande
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
Zilliz
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
DianaGray10
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 

Recently uploaded (20)

Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)Main news related to the CCS TSI 2023 (2023/1695)
Main news related to the CCS TSI 2023 (2023/1695)
 
The Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptxThe Microsoft 365 Migration Tutorial For Beginner.pptx
The Microsoft 365 Migration Tutorial For Beginner.pptx
 
Choosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptxChoosing The Best AWS Service For Your Website + API.pptx
Choosing The Best AWS Service For Your Website + API.pptx
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk"Frontline Battles with DDoS: Best practices and Lessons Learned",  Igor Ivaniuk
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor Ivaniuk
 
A Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's ArchitectureA Deep Dive into ScyllaDB's Architecture
A Deep Dive into ScyllaDB's Architecture
 
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development ProvidersYour One-Stop Shop for Python Success: Top 10 US Python Development Providers
Your One-Stop Shop for Python Success: Top 10 US Python Development Providers
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
Fueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte WebinarFueling AI with Great Data with Airbyte Webinar
Fueling AI with Great Data with Airbyte Webinar
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
What is an RPA CoE? Session 1 – CoE Vision
What is an RPA CoE?  Session 1 – CoE VisionWhat is an RPA CoE?  Session 1 – CoE Vision
What is an RPA CoE? Session 1 – CoE Vision
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 

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