SlideShare une entreprise Scribd logo
1  sur  68
Télécharger pour lire hors ligne
Front-enD God-modE w /
ReagenT AnD FigwheeL
DaviD Y. KaY
State of Front-end Dev
State of the Art
• Write Code
• Reload Browser
• Lose Application State
• Manipulate Application State
• Test/verify behavior
• Repeat
Goal for this Talk
• How to develop code interactively
• Minimal incidental complexity
• Be the coolest kid on the block
Demo
• Show what Pharmasoft / Chat App Looks Like
• Show a one-line change
• Show the recursive nature of components
The Armory
Clojurescript Figwheel Reagent
Why Clojurescript?
Clojurescript
• More sane than JS
• Functional
• S-expressions
• Code is data
(defn square [x]
(* x x))
function square(x){
return x*x;
}
Why Figwheel?
Figwheel
3 Steps:
• Edit
• Save
• Watch in Awe
Bret Victor - Inventing on Principle
Figwheel
• Pro:
• Code changes occur instantly
• App state is maintained
• Con:
• Have to write code so that it’s reloadable
Code Changes
Figwheel Server
(Lein figwheel)
CLJS App
Figwheel
Client
Why Reagent?
Reagent
• a minimal, sleek React.js
• SIMPLE
• Dataflow!
• Likened more to Elm than React.js
Atoms
(defonce app-state
(r/atom {:chat-input ""
:messages []
:username
"Anon"}))
(swap! app-state assoc :username
"David")
(reset! app-state new-state)
Adjust with Feedback
• Show some mis-steps, correct them
Review
• Clojurescript
• Figwheel
• Reagent
Come for the workshop!
MailinG LisT
www.davidykay.com/i-love-clojurescript
ReagenT AnD FigwheeL
WorkshoP
Installing the Tools
brew install leiningen
Running the Code
Terminal 1:
lein ring server
Terminal 2:
lein figwheel
Part 0: Prologue
Set the Goal
• By the end of this workshop, you should be able
to create a chat client using CLJS, Foundation,
Reagent, and Figwheel
• Here’s what it looks like…
Demo
• Show what Chat App Looks Like
Roadmap
• Clojurescript
• Data structures
• Functions
• Figwheel
• Reagent
• Atoms
• Components
• Putting it all together - Chat App
Part 1: Intro
Figwheel
• Pro:
• Code changes occur instantly
• App state is maintained
• Con:
• Have to write code so that it’s reloadable
Hello World
lein new figwheel chat
cd chat
lein figwheel
view localhost:3449
Clojurescript
(defn square [x]
(* x x))
Data Structures
List - ( )
Vector - [ ]
Map - { }
Set - #{ }
(def app-db {:greeting "Hello Van FP!"
:email “david@vanfp.com"
:password ""
:screen :login})
(if (= id (:current-condition @app-
state))
"current"
"")
(fn [n]
(clojure.string/join
" "
"tabs-title"
(if (= n (:active-tab @app-state))
"is-active"
nil)]))
Part 2: Basics
Reagent
Hiccup Syntax
[:div.top-bar-right
[:ul.menu
[:li [:a {:href "#"} "History"]]
[:li [:a {:href "#"} "Log Out"]]]]
Button Handler
[:button {:class "button"
:on-click
#(do
(refresh-messages)
(.preventDefault %))}
"Refresh"]
Button Handler
[:button {:class "button"
:on-click
(fn [ev]
(refresh-messages)
(.preventDefault ev))}
"Refresh"]
Button Handler
(defn handle-click [ev]
(refresh-messages)
(.preventDefault ev))
[:button {:class "button"
:on-click handle-click}
"Refresh"]
Atoms
(defonce app-state
(r/atom {:chat-input ""
:messages []
:username
"Anon"}))
(swap! app-state assoc :username
"David")
(reset! app-state new-state)
Atoms
(swap! app-state assoc :username
“David")
(swap! app-state (fn [old]
(assoc old :username “david”))
(reset! app-state new-state)
Text Input
[:input
{:placeholder "Neo",
:type "text"
:value (:username @app-state)
:on-change
(fn [ev]
(swap! app-state
assoc
:username
(-> ev .-target .-value)))}]
Text Input
(-> ev
.-target
.-value)
(:value (:target ev))
(.-value (.-target ev))
Part 3: Intermediate
HTTP Calls
(GET "/" {:handler (fn [response]
(println response))
:error-handler error-handler})
(defn error-handler
[{:keys [status status-text]}]
(println "error code: " status
" " status-text))
Reagent Component
(defn component [medication]
[:div
[:h2 "Pre-Interview Notes"]
[:p (:general-notes @app-state)]
[:form
...]])
Review
• Figwheel
• Reloadable code
• Clojurescript
• Reagent
• Ratoms
• Components
Resources
• Figwheel Talk at Clojure/West 2015
• Reagent Docs - holmsand.github.io/reagent/
MailinG LisT
www.davidykay.com/i-love-clojurescript
ExtrA ImageS
Front-end God Mode with Reagent and Figwheel
Front-end God Mode with Reagent and Figwheel
Front-end God Mode with Reagent and Figwheel

Contenu connexe

Tendances

The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
Sashko Stubailo
 
Why should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming ParadigmWhy should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming Paradigm
Tech Triveni
 

Tendances (20)

[JCConf 2017] Reactive Programming with Reactor
[JCConf 2017] Reactive Programming with Reactor[JCConf 2017] Reactive Programming with Reactor
[JCConf 2017] Reactive Programming with Reactor
 
Engineering Efficiency in LINE
Engineering Efficiency in LINEEngineering Efficiency in LINE
Engineering Efficiency in LINE
 
Elixir + GraphQL = Absinthe 2019.04.10
Elixir + GraphQL = Absinthe 2019.04.10Elixir + GraphQL = Absinthe 2019.04.10
Elixir + GraphQL = Absinthe 2019.04.10
 
GraphQL With Relay Part Deux
GraphQL With Relay Part DeuxGraphQL With Relay Part Deux
GraphQL With Relay Part Deux
 
Domain Driven Rails
Domain Driven RailsDomain Driven Rails
Domain Driven Rails
 
GraphQL in an Age of REST
GraphQL in an Age of RESTGraphQL in an Age of REST
GraphQL in an Age of REST
 
Design Summit - UI Roadmap - Dan Clarizio, Martin Povolny
Design Summit - UI Roadmap - Dan Clarizio, Martin PovolnyDesign Summit - UI Roadmap - Dan Clarizio, Martin Povolny
Design Summit - UI Roadmap - Dan Clarizio, Martin Povolny
 
Flowex - Railway Flow-Based Programming with Elixir GenStage.
Flowex - Railway Flow-Based Programming with Elixir GenStage.Flowex - Railway Flow-Based Programming with Elixir GenStage.
Flowex - Railway Flow-Based Programming with Elixir GenStage.
 
GraphQL + relay
GraphQL + relayGraphQL + relay
GraphQL + relay
 
The Apollo and GraphQL Stack
The Apollo and GraphQL StackThe Apollo and GraphQL Stack
The Apollo and GraphQL Stack
 
GraphQL
GraphQLGraphQL
GraphQL
 
Jetpack joyride!
Jetpack joyride!Jetpack joyride!
Jetpack joyride!
 
OUG Ireland 2019 - building free, open-source, PL/SQL products in cloud
OUG Ireland 2019 - building free, open-source, PL/SQL products in cloudOUG Ireland 2019 - building free, open-source, PL/SQL products in cloud
OUG Ireland 2019 - building free, open-source, PL/SQL products in cloud
 
Why should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming ParadigmWhy should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming Paradigm
 
Roslyn
RoslynRoslyn
Roslyn
 
ruby-on-rails-and-ember-cli
ruby-on-rails-and-ember-cliruby-on-rails-and-ember-cli
ruby-on-rails-and-ember-cli
 
Elixir and elm - the perfect couple
Elixir and elm - the perfect coupleElixir and elm - the perfect couple
Elixir and elm - the perfect couple
 
Modular GraphQL with Schema Stitching
Modular GraphQL with Schema StitchingModular GraphQL with Schema Stitching
Modular GraphQL with Schema Stitching
 
Introduction to GraphQL
Introduction to GraphQLIntroduction to GraphQL
Introduction to GraphQL
 
Adding GraphQL to your existing architecture
Adding GraphQL to your existing architectureAdding GraphQL to your existing architecture
Adding GraphQL to your existing architecture
 

Similaire à Front-end God Mode with Reagent and Figwheel

Similaire à Front-end God Mode with Reagent and Figwheel (20)

ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
Building a web application with ontinuation monads
Building a web application with ontinuation monadsBuilding a web application with ontinuation monads
Building a web application with ontinuation monads
 
Guides To Analyzing WebKit Performance
Guides To Analyzing WebKit PerformanceGuides To Analyzing WebKit Performance
Guides To Analyzing WebKit Performance
 
ClojureScript interfaces to React
ClojureScript interfaces to ReactClojureScript interfaces to React
ClojureScript interfaces to React
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native
 
Tools and practices for rapid application development
Tools and practices for rapid application developmentTools and practices for rapid application development
Tools and practices for rapid application development
 
ClojureScript for the web
ClojureScript for the webClojureScript for the web
ClojureScript for the web
 
JS Essence
JS EssenceJS Essence
JS Essence
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
Javascript
JavascriptJavascript
Javascript
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
 
Griffon for the Enterprise
Griffon for the EnterpriseGriffon for the Enterprise
Griffon for the Enterprise
 
German introduction to sp framework
German   introduction to sp frameworkGerman   introduction to sp framework
German introduction to sp framework
 
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)
 
O365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - MaterialO365 Developer Bootcamp NJ 2018 - Material
O365 Developer Bootcamp NJ 2018 - Material
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014
 
Om nom nom nom
Om nom nom nomOm nom nom nom
Om nom nom nom
 

Plus de David Kay

App architecture101
App architecture101App architecture101
App architecture101
David Kay
 

Plus de David Kay (6)

Cross platform native development in f#
Cross platform native development in f#Cross platform native development in f#
Cross platform native development in f#
 
How to Start a Med Device Startup From Your Garage - Vancouver Edition
How to Start a Med Device Startup From Your Garage - Vancouver EditionHow to Start a Med Device Startup From Your Garage - Vancouver Edition
How to Start a Med Device Startup From Your Garage - Vancouver Edition
 
Drag and Drop UI Development with React Native
Drag and Drop UI Development with React NativeDrag and Drop UI Development with React Native
Drag and Drop UI Development with React Native
 
Intro to Apache Storm
Intro to Apache StormIntro to Apache Storm
Intro to Apache Storm
 
App architecture101
App architecture101App architecture101
App architecture101
 
Slaying Bugs with Gradle and Jenkins
Slaying Bugs with Gradle and JenkinsSlaying Bugs with Gradle and Jenkins
Slaying Bugs with Gradle and Jenkins
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Dernier (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

Front-end God Mode with Reagent and Figwheel