THE IMMUTABLE FRONTEND IN CLOJURESCRIPT
Logan Linn (@loganlinn) QCon SF 2014
1
THE IMMUTABLE FRONTEND IN CLOJURESCRIPT Logan Linn (@loganlinn) - - PowerPoint PPT Presentation
THE IMMUTABLE FRONTEND IN CLOJURESCRIPT Logan Linn (@loganlinn) QCon SF 2014 1 PRISMATIC Personalized, interest-based newsfeeds Crawlers, Machine Learning, Clients Were very functional 99.9% Clojure backend ClojureScript frontend We
Logan Linn (@loganlinn) QCon SF 2014
1
2
3
4
5
React App State User Events API Data Component Tree D O M
6
7
8
9
10
animate
11
Controller Model View
12
13
14
15
Controller Model View
16
Controller Model View
DOM User Events
17
Pure Render
18
DOM App State User Events
19
20
21
22
23
24
25
26
27
a b c
28
Dynamic, Functional, Lisp Clojure Compiles to JVM bytecode 7 years old ClojureScript Compiles to JavaScript 3 years old
29
30
—Alan Perlis, 1982
31
(def state-ref (atom {})) (deref state-ref) ;; => {} (reset! state-ref {:a 1}) @state-ref ;; => {:a 1} (defn increment-a [state] (update-in state [:a] inc)) (increment-a @state-ref) ;; => {:a 2} @state-ref ;; => {:a 1} (swap! state-ref increment-a) @state-ref ;; => {:a 2}
32
33
34
35
React App State User Events HTTP Data Component Tree D O M
state
36
component component component state component
37
state component component component component
38
state component component component component
39
state component component
40
state component
41
state component
42
component tree
actions
43
state component tree
44
state component tree
45
component tree
46
S1
component tree
S2
47
React App State User Events HTTP Data Component Tree D O M
48
49
App State
50
React D O M
51
52
React D O M
53
DOM2
54
S1
D1
S2
D2
React DOM1
55
56
@loganlinn @prismatic
57