2. Reactive Programming
Wikipedia ์ ์ฒซ ๊ตฌ์ ์ ์ ํํ๋์ด ์๋ค.
โ data flow (<-> control flow)
โ graph of data
โ propagation of change
โ express static or dynamic data flows with ease in the programming
languages used
โ the underlying execution model will automatically propagate changes
through the data flow
5. Reactive Programming
โ x = 10
โ y = x + 1
โ print y
; => 11
โ x = 20
โ print y
; => 11
โ y = x + 1
โ print y
; => 21
โ x = 10
โ y = x + 1
โ print y
; => 11
โ x = 20
โ print y
; => 21
imperative reactive
6. Reactive Programming
โ x = 10
โ y = x + 1
โ print y
; => 11
โ x = 20
โ print y
; => 11
โ y = x + 1
โ print y
; => 21
imperative
propagation of change
๋ช ์์ ,
์๋์
์๋ฌต์ ,
์๋์
โ x = 10
โ y = x + 1
โ print y
; => 11
โ x = 20
โ print y
; => 21
reactive
7. Reactive Programming
โ x = 10
โ y = x + 1
โ print y
; => 11
โ x = 20
โ print y
; => 11
โ y = x + 1
โ print y
; => 21
โ x = 10
โ y = x + 1
โ print y
; => 11
โ x = 20
โ print y
; => 21
imperative reactive
statement definition
12. Reactive Programming
Wikipedia ์ ์ฒซ ๊ตฌ์ ์ ์ ํํ๋์ด ์๋ค.
โ data flow (<-> control flow)
โ graph of data
โ propagation of change
โ express static or dynamic data flows with ease in the programming
languages used
โ the underlying execution model will automatically propagate changes
through the data flow
๊ด๊ณ(relation)
๊ด๊ณ์ ์ฌํ์ฑ
๊ด๊ณ์ ์ง์
15. Reactive Programming
Wikipedia ์ ์ฒซ ๊ตฌ์ ์ ์ ํํ๋์ด ์๋ค.
โ data flow (<-> control flow)
โ graph of data
โ propagation of change
โ express static or dynamic data flows with ease in the programming
languages used
โ the underlying execution model will automatically propagate changes
through the data flow
16. Reactive Programming
Wikipedia ์ ์ฒซ ๊ตฌ์ ์ ์ ํํ๋์ด ์๋ค.
โ data flow (<-> control flow)
โ graph of data
โ propagation of change
โ express static or dynamic data flows with ease in the programming
languages used
โ the underlying execution model will automatically propagate changes
through the data flow
FP, Monad
17. Reactive Programming
Wikipedia ์ ์ฒซ ๊ตฌ์ ์ ์ ํํ๋์ด ์๋ค.
โ data flow (<-> control flow)
โ graph of data
โ propagation of change
โ express static or dynamic data flows with ease in the programming
languages used
โ the underlying execution model will automatically propagate changes
through the data flow
FP, Macro
19. re-frame
D V
signal signal
FB React
React
Component
Virtual
DOM
Browser
DOM
Browser
Rendering
โ No Observation
โ No Monad
โ No Event
โ No model dirty checking!
โ No Data Binding!
โ Diffing Algorithm
โ Re-render the whole app on every
update
โ One Way
22. re-frame
Reagent Componet
(defn hello []
[:h1 โhelloโ]) hello
Reagent Component Browser
โ Just a function that returns hiccup.
โ Not yet signal
โ Need atom
render โhelloโ
<h1> hello </h1>
23. re-frame
Atom : State for Clojure
โ (def x (atom 1))
โ @x ;=> 1
โ (swap! x inc)
โ @x ;=> 2
โ (swap! x + 10)
โ @x ;=> 12
โ (reset! x 1)
โ @x ;=> 1
โ (def x (atom 1))
โ (defn f [] (prn โx = โ @x))
โ (f)
;>> โx = 1โ
โ (swap! x inc)
โ (f)
;>> โx = 2โ
atom ๋ง์ผ๋ก๋
์๋๋ค.
๋ช ์์ ์ผ๋ก
ํธ์ถํด์ค์ผ...
๋ณ๊ฒฝํ์ง
๋ง
24. re-frame
Ratom : State for Reagent
โ Clojure์ Atom๊ณผ ๋ชจ๋ ๊ธฐ๋ฅ์ ๋๊ฐ๋ค.
โ Reagent Component์ State๋ก์ ๋์ํ๋๋ก ๊ธฐ๋ฅ์ด ์ถ๊ฐ๋์๋ค.
โ reagent๊ฐ mountํ ๋, Ratom์ ์ฌ์ฉํ๋ ํจ์๋ reagent
component๊ฐ ๋ฑ๋กํ๊ฒ ๋๋ค. ์ด๋ ๊ฒ ํด์ signal์ด ๋๋ค.
โ (def x (r/atom 1))
โ @x ;=> 1
โ (swap! x inc)
โ @x ;=> 2
โ (swap! x + 10)
โ @x ;=> 12
โ (reset! x 1)
โ @x ;=> 1
โ (def x (r/atom 1))
โ (defn f [] (prn โx = โ @x))
โ ; reagent mount f as component
โ (swap! x inc)
;>> โx = 2โ
๋ณ๊ฒฝํ
๋ฉด
์๋์ผ๋ก
ํธ์ถ๋๋ค
26. re-frame
Reagent component
โ ํ๋ฉด์ ๊ตฌ์ฑํ๋ค๋ ๊ฒ์ ๊ณง ๋ฐ์ดํ๋ฅผ ๊ตฌ์ฑํ๋ค๋
๊ฒ
โ ๋ฐ์ดํ ์กฐ์๋ง์ผ๋ก ํ๋ฉด์ ๊ตฌ์ฑํ ์ ์๋ค!
D V
signal signal
D
signal
Ratom
29. re-frame
Reagent component
D V
signal signal
D
signal
Ratom
Reagent component
D V
signal signal
D
signal
Ratom
2 Ratom ์ฌ์ด์ ๊ด๊ณ๊ฐ ์์ด์ผโฆ
์ฆ ํ Ratom์ ๋ณํ๊ฐ ๋ค๋ฅธ Ratom์
์ ํ๋์ด์ผ...
30. re-frame
Reagent component
D V
signal signal
D
signal
Ratom
Reagent component
D V
signal signal
D
signal
Ratom
๊ทธ๋ฌ๋ Ratom์๋ ์ด๋ฐ ๊ธฐ๋ฅ์ด ์๋ค.
โณ
31. re-frame
Reagent component
D V
signal signal
D
signal
Ratom
Reagent component
D V
signal signal
D
signal
Reaction
Reaction์ด ๊ทธ ์ญํ ์ ํ ์ ์๋ค.
Reaction
35. re-frame
Reagent component
D V
signal signalD
signal
Ratom
Reagent component
D V
signal signal
D
signal
Reaction
Reaction์ ๋ค์์ ์๊ทธ๋์ ๊ฒฐํฉํด์ ๊ณ์ฐ์ ์ํํ๊ณ ๊ทธ ๊ฒฐ๊ณผ๋ฅผ ๋ฆฌํดํ ์
์๋ค.
D
signal
Ratom
Reaction ์ ์ฅ์ 1
37. re-frame
Reagent component
D V
signal signal
D
signal
Ratom
Reagent component
D V
signal signal
D
signal
Reaction
Reaction ์ ์ฅ์ 2
Reaction์ ๊ด์ฌ์๋ ๋ถ๋ถ์ ๋ณํ๋ง ์ ํํ ์
์๋ค.
part
part