Lightning Chess
The fun way of learning the Lightning Component Framework
Sri Lanka Salesforce Developer Group 2016-12-8 #SFLightningChess #SalesforceDevs
1
Who am I?
2
Samuel De Rycke
Technical Architect
Talent Management
4.5 years SF experience
Salesforce MVP
Belgium User Group
Leader
Belgium Developer
Group Leader
Salesforce.Stackexchange
Moderator
Dreamforce Speaker
}ABSI
@SamuelDeRycke
Implementation
Partner
@absi_nv
Agenda
● Demo
● Lightning Component Framework
● Component Encapsulation
● Lightning Chess: Component Composition
● Event Driven Architecture
● Lightning Chess: Event Driven approach
● Let’s code it
● Q&A
3
Lightning Chess
● R&D project
● Effort: 40 hours + rework
● Chess application on the Salesforce Platform
● Realtime multiplayer game
● Built using Lightning Component framework
Lightning what?!
4
Application Architecture
Streaming API
Custom
Objects
Apex
Controllers
Lightning Chess
Player ClientsLightning Chess
Player Clients
ServerCall
Subscribe
Updates
Salesforce Platform
5
Time for a demo
Demo: Lightning Chess
6
Lightning Component Framework
● Lightning Application
● Lightning Components
● Lightning Events
The Fundamentals
7
Component Bundle
Lightning Component
Component Bundle
Component
< markup />
Style
CSS
Renderer
Javascript
Controller
Javascript
Helper
Javascript
Design
< markup />
Documentation
< markup />
SVG File
8
Component Encapsulation
● Object Oriented Programming principles
● Internals are not exposed to the outside
● Public vs Private interface
What happens in the component, stays in the component
Component
Public:
● Public Attributes
● Public Methods
● Events
Private:
● HTML DOM
● CSS Style
● Private Attributes
● Controller Functions
● Helper Functions
● Apex Controller
9
Component Encapsulation
● Easy to reuse
Use them in different applications or other components making use of a component’s public interface
● Open for extension
Extend the functionality of a component without impacting other components. Less bugs.
● Independent
A component does not rely on its consumers but on its public interface to function. This makes it easy to use a component in any
system or application.
● Compact
Separation of Concerns will lead to code that is small and easy to maintain, debug and test.
Components can be:
“Think Component Encapsulation“
10
Lightning Chess: Component Architecture
Divide and conquer
Streaming API Listener
General Game Component
Chessboard
Chessboard Location
Streaming API Listener
Player List
Challenge List
Streaming API Listener
Streaming API Listener
Subscribe to streaming
API and forward
streaming event
messages
Streaming API Listener
11
Lightning Chess: Streaming API Listener
<aura:component>
<!-- public interface -->
<aura:attribute name=”listeners” type=”String[]” access=”public”/>
<aura:registerEvent name=”StreamingEvent” type=”c:StreamingEvent” />
<!-- private interface -->
<ltng:require scripts="<!--Required scripts -->" afterScriptsLoaded="{!c.setupStreaming}" />
<aura:attribute name="sessionId" type="String" access="private"/>
<aura:handler name="destroy" value="{!this}" action="{!c.closeConnections}"/>
</aura:component>
12
Lightning Chess: Component Architecture
Mistakes were made
Chessboard
Chessboard Location
Streaming API Listener
Player List
Challenge List
Streaming API Listener
Streaming API ListenerChessboard has too much responsibility. What if
we want to extend and allow users to choose what
game they want to play?
“Single Responsibility“
13
Lightning Chess: Component architecture
Mistakes were made
Streaming API Listener
General Game Component
Chessboard
Chessboard Location
Streaming API Listener
Player List
Challenge List
Streaming API Listener
Streaming API Listener
Streaming API Listener
14
“Single Responsibility“
Event Driven Architecture
Event types
<aura:event type=”Component” description=”Chessboard_Location_Select”>
<aura:attribute name=”location” type=”Object” />
</aura:event>
15
Component Event Application Event
Send only to components in the parent
hierarchy above
Broadcast to the entire Lighting
Application.
Tighter coupling between sender and
receivers
Very loose coupling between sender
and receivers
Event Driven Architecture
● Part of the public interface
● “Something happened, I don’t know what to do, so do whatever you like!”
Loosely coupled communication
<aura:component description=”Chessboard_Location”>
<!-- Chessboard Location Component Definition -->
!-- Public Interface-->
<aura:registerEvent name=”select” type=”c:Chessboard_Location_Select” />
</aura:component>
<aura:component description=”Chessboard”>
<!-- Chessboard component Definition -->
<!-- Chessboard has a Chessboard Location component and subscribes a handler to the
select component event-->
<c:Chessboard_Location select=”{!c.handleLocationSelect}” />
</aura:component>
16
Lightning Chess: Event Driven Approach
Communication is key
Chessboard
Chessboard Location Streaming API Listener
Chess Logic
Server Call
I am selected as
a starting
location
I am selected as
a target location
Locations x,y
please mark
yourself as
targetable
I received a new
move with
following details
Following
piece moved
from x to y
Click
Click
“Loose communication through Events“ 17
Let’s Code !
Extend the Chessboard Location component by adding drag-and-drop
support.
18
Summary
Takeaways
“Think Component Encapsulation“
“Single Responsibility“
“Loose communication through Events“
19
Resources
Code @ Github!
http://bit.ly/LightningChess-Code
Read more about Lightning Chess Architecture:
http://bit.ly/LightningChess-Blog
20
Questions ?
Reach me on twitter @SamuelDeRycke #SFLightningChess
21
thank y u
22

More Related Content

PDF
Build a REST API for your Mobile Apps using Node.js
PDF
Exposing Salesforce REST Services Using Swagger
PPTX
REST API Security: OAuth 2.0, JWTs, and More!
PDF
Take Action with Forge Triggers
PPTX
Making your API behave like a big boy
PDF
Declaring Server App Components in Pure Java
PPTX
Building a scalable API with Grails
PDF
Kasten securing access to your kubernetes applications
Build a REST API for your Mobile Apps using Node.js
Exposing Salesforce REST Services Using Swagger
REST API Security: OAuth 2.0, JWTs, and More!
Take Action with Forge Triggers
Making your API behave like a big boy
Declaring Server App Components in Pure Java
Building a scalable API with Grails
Kasten securing access to your kubernetes applications

What's hot (20)

PPTX
Spring Boot Authentication...and More!
PPTX
Enhance existing REST APIs (e.g. Facebook Graph API) with code completion us...
PPT
Nakal think test_2015
PDF
What is IBM Bluemix , Une nouvelle façon de coder , dans le cloud
PPTX
Azure cloud for the web frontend developers
PDF
I Love APIs 2015: Advanced Security Extensions in Apigee Edge - HMAC and http...
PDF
Building a Cerberus App Without Losing Our Heads: The Passage to a Cross-Plat...
PDF
Building Enterprise Apps with Sencha ExtJS/Touch & DeftJS
PPTX
Document your rest api using swagger - Devoxx 2015
PPTX
Let's Jira do the work
PDF
Practical Patterns for Developing a Cross-product Cross-version App
PDF
Building Secure Apps in the Cloud
PDF
Lwc presentation
PDF
API Developer Experience: Why it Matters, and How Documenting Your API with S...
PDF
API Description Languages
PPTX
Api Design
PPTX
Api gateway : To be or not to be
PDF
From AUI to Atlaskit - Streamlining Development for Server & Cloud Apps
PDF
Designing and Running a GraphQL API
PPTX
Stormpath 101: Spring Boot + Spring Security
Spring Boot Authentication...and More!
Enhance existing REST APIs (e.g. Facebook Graph API) with code completion us...
Nakal think test_2015
What is IBM Bluemix , Une nouvelle façon de coder , dans le cloud
Azure cloud for the web frontend developers
I Love APIs 2015: Advanced Security Extensions in Apigee Edge - HMAC and http...
Building a Cerberus App Without Losing Our Heads: The Passage to a Cross-Plat...
Building Enterprise Apps with Sencha ExtJS/Touch & DeftJS
Document your rest api using swagger - Devoxx 2015
Let's Jira do the work
Practical Patterns for Developing a Cross-product Cross-version App
Building Secure Apps in the Cloud
Lwc presentation
API Developer Experience: Why it Matters, and How Documenting Your API with S...
API Description Languages
Api Design
Api gateway : To be or not to be
From AUI to Atlaskit - Streamlining Development for Server & Cloud Apps
Designing and Running a GraphQL API
Stormpath 101: Spring Boot + Spring Security
Ad

Viewers also liked (9)

PPTX
Getting Certified - proven tips for success (French Touch Dreamin)
PPTX
Spring '16 release belgium salesforce user group samuel de rycke
PPTX
Salesforce APIs
PPTX
Salesforce1 API Overview
PPTX
Asynchronous Apex Salesforce World Tour Paris 2015
PPTX
Integration with the Salesforce App Cloud - Amsterdam 2016
PPTX
Salesforce Flexible Pages
PDF
Banish The Buzzwords
PPTX
A Taste of Lightning in Action
Getting Certified - proven tips for success (French Touch Dreamin)
Spring '16 release belgium salesforce user group samuel de rycke
Salesforce APIs
Salesforce1 API Overview
Asynchronous Apex Salesforce World Tour Paris 2015
Integration with the Salesforce App Cloud - Amsterdam 2016
Salesforce Flexible Pages
Banish The Buzzwords
A Taste of Lightning in Action
Ad

Similar to Lightning Chess at the Sri Sanka Salesforce Developer Group (11)

PPTX
Lightning Chess, The fun way to learn the Lightning Component Framework
PPTX
Lightning chess
PDF
Lightning Components - Down Under Dreaming Sydney
PDF
Deep diving into building lightning components
PPTX
Dreamforce 2017 - Advanced Logging Patterns with Platform Events
PPTX
Denver Salesforce Developer User Group dec 2016 lightning components
PDF
The Road To Event-Driven Architecture
PDF
Get Struck By Lightning
PPTX
Lightning Component - Components, Actions and Events
PDF
004 - JavaFX Tutorial - Event Handling
PDF
Salesforce Lightning Development What Do You Need to Know.pdf
Lightning Chess, The fun way to learn the Lightning Component Framework
Lightning chess
Lightning Components - Down Under Dreaming Sydney
Deep diving into building lightning components
Dreamforce 2017 - Advanced Logging Patterns with Platform Events
Denver Salesforce Developer User Group dec 2016 lightning components
The Road To Event-Driven Architecture
Get Struck By Lightning
Lightning Component - Components, Actions and Events
004 - JavaFX Tutorial - Event Handling
Salesforce Lightning Development What Do You Need to Know.pdf

Recently uploaded (20)

PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Five Habits of High-Impact Board Members
PDF
A review of recent deep learning applications in wood surface defect identifi...
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPT
Module 1.ppt Iot fundamentals and Architecture
PPT
Geologic Time for studying geology for geologist
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
Hybrid model detection and classification of lung cancer
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
A comparative study of natural language inference in Swahili using monolingua...
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Taming the Chaos: How to Turn Unstructured Data into Decisions
NewMind AI Weekly Chronicles – August ’25 Week III
Zenith AI: Advanced Artificial Intelligence
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
A novel scalable deep ensemble learning framework for big data classification...
Getting started with AI Agents and Multi-Agent Systems
Five Habits of High-Impact Board Members
A review of recent deep learning applications in wood surface defect identifi...
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Module 1.ppt Iot fundamentals and Architecture
Geologic Time for studying geology for geologist
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Group 1 Presentation -Planning and Decision Making .pptx
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
Hybrid model detection and classification of lung cancer
Benefits of Physical activity for teenagers.pptx
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game

Lightning Chess at the Sri Sanka Salesforce Developer Group

  • 1. Lightning Chess The fun way of learning the Lightning Component Framework Sri Lanka Salesforce Developer Group 2016-12-8 #SFLightningChess #SalesforceDevs 1
  • 2. Who am I? 2 Samuel De Rycke Technical Architect Talent Management 4.5 years SF experience Salesforce MVP Belgium User Group Leader Belgium Developer Group Leader Salesforce.Stackexchange Moderator Dreamforce Speaker }ABSI @SamuelDeRycke Implementation Partner @absi_nv
  • 3. Agenda ● Demo ● Lightning Component Framework ● Component Encapsulation ● Lightning Chess: Component Composition ● Event Driven Architecture ● Lightning Chess: Event Driven approach ● Let’s code it ● Q&A 3
  • 4. Lightning Chess ● R&D project ● Effort: 40 hours + rework ● Chess application on the Salesforce Platform ● Realtime multiplayer game ● Built using Lightning Component framework Lightning what?! 4
  • 5. Application Architecture Streaming API Custom Objects Apex Controllers Lightning Chess Player ClientsLightning Chess Player Clients ServerCall Subscribe Updates Salesforce Platform 5
  • 6. Time for a demo Demo: Lightning Chess 6
  • 7. Lightning Component Framework ● Lightning Application ● Lightning Components ● Lightning Events The Fundamentals 7
  • 8. Component Bundle Lightning Component Component Bundle Component < markup /> Style CSS Renderer Javascript Controller Javascript Helper Javascript Design < markup /> Documentation < markup /> SVG File 8
  • 9. Component Encapsulation ● Object Oriented Programming principles ● Internals are not exposed to the outside ● Public vs Private interface What happens in the component, stays in the component Component Public: ● Public Attributes ● Public Methods ● Events Private: ● HTML DOM ● CSS Style ● Private Attributes ● Controller Functions ● Helper Functions ● Apex Controller 9
  • 10. Component Encapsulation ● Easy to reuse Use them in different applications or other components making use of a component’s public interface ● Open for extension Extend the functionality of a component without impacting other components. Less bugs. ● Independent A component does not rely on its consumers but on its public interface to function. This makes it easy to use a component in any system or application. ● Compact Separation of Concerns will lead to code that is small and easy to maintain, debug and test. Components can be: “Think Component Encapsulation“ 10
  • 11. Lightning Chess: Component Architecture Divide and conquer Streaming API Listener General Game Component Chessboard Chessboard Location Streaming API Listener Player List Challenge List Streaming API Listener Streaming API Listener Subscribe to streaming API and forward streaming event messages Streaming API Listener 11
  • 12. Lightning Chess: Streaming API Listener <aura:component> <!-- public interface --> <aura:attribute name=”listeners” type=”String[]” access=”public”/> <aura:registerEvent name=”StreamingEvent” type=”c:StreamingEvent” /> <!-- private interface --> <ltng:require scripts="<!--Required scripts -->" afterScriptsLoaded="{!c.setupStreaming}" /> <aura:attribute name="sessionId" type="String" access="private"/> <aura:handler name="destroy" value="{!this}" action="{!c.closeConnections}"/> </aura:component> 12
  • 13. Lightning Chess: Component Architecture Mistakes were made Chessboard Chessboard Location Streaming API Listener Player List Challenge List Streaming API Listener Streaming API ListenerChessboard has too much responsibility. What if we want to extend and allow users to choose what game they want to play? “Single Responsibility“ 13
  • 14. Lightning Chess: Component architecture Mistakes were made Streaming API Listener General Game Component Chessboard Chessboard Location Streaming API Listener Player List Challenge List Streaming API Listener Streaming API Listener Streaming API Listener 14 “Single Responsibility“
  • 15. Event Driven Architecture Event types <aura:event type=”Component” description=”Chessboard_Location_Select”> <aura:attribute name=”location” type=”Object” /> </aura:event> 15 Component Event Application Event Send only to components in the parent hierarchy above Broadcast to the entire Lighting Application. Tighter coupling between sender and receivers Very loose coupling between sender and receivers
  • 16. Event Driven Architecture ● Part of the public interface ● “Something happened, I don’t know what to do, so do whatever you like!” Loosely coupled communication <aura:component description=”Chessboard_Location”> <!-- Chessboard Location Component Definition --> !-- Public Interface--> <aura:registerEvent name=”select” type=”c:Chessboard_Location_Select” /> </aura:component> <aura:component description=”Chessboard”> <!-- Chessboard component Definition --> <!-- Chessboard has a Chessboard Location component and subscribes a handler to the select component event--> <c:Chessboard_Location select=”{!c.handleLocationSelect}” /> </aura:component> 16
  • 17. Lightning Chess: Event Driven Approach Communication is key Chessboard Chessboard Location Streaming API Listener Chess Logic Server Call I am selected as a starting location I am selected as a target location Locations x,y please mark yourself as targetable I received a new move with following details Following piece moved from x to y Click Click “Loose communication through Events“ 17
  • 18. Let’s Code ! Extend the Chessboard Location component by adding drag-and-drop support. 18
  • 19. Summary Takeaways “Think Component Encapsulation“ “Single Responsibility“ “Loose communication through Events“ 19
  • 20. Resources Code @ Github! http://bit.ly/LightningChess-Code Read more about Lightning Chess Architecture: http://bit.ly/LightningChess-Blog 20
  • 21. Questions ? Reach me on twitter @SamuelDeRycke #SFLightningChess 21