Slide 1

Slide 1 text

Clojure and ClojureScript programming competition September 28-29 Signup opens September 7, 03:00 EEST clojurecup.com @clojurecup

Slide 2

Slide 2 text

@abedra @amitrathore @marick @cemerick @ibdknox @chrishouser @cgrand @lisperati @swannodette @deanwampler @garybernhardt @hlship @weavejester @w01fe @antiheroine @nrrrdcore @lynaghk @michaelklishin @bmf @nathanmarz @neal4d @usabilitycounts@technomancy @samaaron @venkat_s

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Help Needed • Monitoring, IRC ops, contestant support during the competition. • May not participate in compo • Ping me at [email protected]

Slide 5

Slide 5 text

Single Page Webapps in ClojureScript with Pedestal Tero Parviainen clojuTRE 2013

Slide 6

Slide 6 text

Tero Parviainen @teropa Freelance software maker. Clojure, Java, Ruby, JavaScript. Web, Android, iOS, WP.

Slide 7

Slide 7 text

tinyurl.com/vertxbook September 2013 Packt Publishing

Slide 8

Slide 8 text

Webapps: A Personal History

Slide 9

Slide 9 text

Web Frameworks

Slide 10

Slide 10 text

AJAX

Slide 11

Slide 11 text

http://www.flickr.com/photos/andrec/109984452/

Slide 12

Slide 12 text

Google Web Toolkit

Slide 13

Slide 13 text

http://www.flickr.com/photos/seattlemunicipalarchives/8284074749/

Slide 14

Slide 14 text

Single-page

Slide 15

Slide 15 text

http://hipstergrammers.tumblr.com/

Slide 16

Slide 16 text

ClojureScript

Slide 17

Slide 17 text

http://www.flickr.com/photos/32820477@N02/3619048502/

Slide 18

Slide 18 text

Pedestal

Slide 19

Slide 19 text

The Hook (ns hello-world (:require [domina :as dom])) (def application-state (atom 0)) (defn render [old-state new-state] (dom/destroy-children! (dom/by-id "content")) (dom/append! (dom/by-id "content") (str "

" new-state " Hello Worlds

"))) (add-watch application-state :app-watcher (fn [key reference old-state new-state] (render old-state new-state))) (defn receive-input [] (swap! application-state inc) (.setTimeout js/window #(receive-input) 3000)) (defn ^:export main [] (receive-input))

Slide 20

Slide 20 text

“If you have ever built a ClojureScript application, this is the way you start.”

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

What Pedestal Is Pedestal Services Pedestal Applications Clojure ClojureScript Web Services Tooling Browser Applications Tooling

Slide 23

Slide 23 text

What Pedestal Is Pedestal Applications ClojureScript Browser Applications Tooling

Slide 24

Slide 24 text

Three Models Google http://domain.com Web Page Title DERP ERP Human Resources 90% Process Compliance 300Hz Big Data Synergy 20 clouds Data Model Application Model DOM

Slide 25

Slide 25 text

Data Model {:todos ["one" "two" "three"]}

Slide 26

Slide 26 text

Application Model {:main {:todos ["one" "two" "three"] :todo-count 3}}

Slide 27

Slide 27 text

Application Model [:node-create [] :map] [:node-create [:main] :map] [:node-create [:main :todos] :map] [:value [:main :todos] nil ["one" "two" "three"]] [:node-create [:main :todo-count] :map] [:value [:main :todo-count] nil 3] Deltas

Slide 28

Slide 28 text

DOM

3 ToDos

  • one
  • two
  • three

Slide 29

Slide 29 text

Verbs over Nouns Data Model Messages User actions HTTP responses SSEs WebSocket input Timer events Transforms Transforms

Slide 30

Slide 30 text

Verbs over Nouns Application Model Data Model Transforms Data Flow

Slide 31

Slide 31 text

Verbs over Nouns DOM Application Model Render Google http://domain.com Web Page Title DERP ERP Human Resources 90% Process Compliance 300Hz Big Data Synergy 20 clouds

Slide 32

Slide 32 text

Decoupling http://www.flickr.com/photos/marfis75/5983944342/

Slide 33

Slide 33 text

Models from Processes Data Model Messages User actions HTTP responses SSEs WebSocket input Timer events Transforms Transforms Pure functions

Slide 34

Slide 34 text

Models from Processes Application Model Data Model Transforms Data Flow Pure functions

Slide 35

Slide 35 text

Messages from Events Data Model Messages User actions HTTP responses SSEs WebSocket input Timer events Transforms Transforms Simulated Simulated Simulated Simulated Simulated

Slide 36

Slide 36 text

App Model From DOM Data UI Application Model Render Google http://domain.com Web Page Title :metrics :human-resources :compliance :big-data-synergy Automated {:amt 90 :unit “%”} {:amt 300 :unit “Hz”} {:amt 20 :unit “Clouds”}

Slide 37

Slide 37 text

Dispatch from Execution Messages Transforms Data Flow Data Model Application Model Rendering DOM Input Queue App Model Queue

Slide 38

Slide 38 text

Dispatch from Execution Messages Transforms Data Flow Data Model Application Model Rendering DOM Input Queue App Model Queue Foreground Background Web Worker

Slide 39

Slide 39 text

Code

Slide 40

Slide 40 text

Resources https://github.com/pedestal/app-tutorial/ http://pedestal.io/ twitter.com/teropa