-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
231 lines (208 loc) · 9.63 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Prez</title>
<meta name="description" content="-- DESCRIPTION HERE --">
<meta name="author" content="cspeisman">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/solarized.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="css/highlight/styles/zenburn.css" id="highlight-theme">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<link rel="stylesheet" href="css/custom.css">
</head>
<body>
<div class="reveal">
<div class="slides"><section id="welcome" class="slide">
<h1>What the flux??</h1><p>(flux and redux)</p>
</section>
<section id="agenda" class="slide">
<h2>Flux, Redux</h2><ul>
<li><p>functional programming</p>
</li>
<li><p>Flux architecture</p>
</li>
<li><p>Redux</p>
</li>
</ul>
</section>
<section id="fp-intro" class="slide">
<h2>Functional Programming</h2><ul>
<li><p>No side effects</p>
<ul>
<li>takes an input and returns a value (pure functions)</li>
<li>No side effects, or outside manipulations</li>
<li>if given the same input it will always return the same value</li>
<li>STATELESS!</li>
</ul>
</li>
<li><p>Easy to unit test</p>
</li>
</ul>
</section>
<section id="fp-example" class="slide">
<p>stateless</p>
<pre><code> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">countUsers</span><span class="hljs-params">(users)</span> {</span>
<span class="hljs-keyword">return</span> users.<span class="hljs-built_in">length</span>
}
</code></pre>
</section>
<section id="fp-example" class="slide">
<p>stateless</p>
<pre><code> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">countDeactivatedUsers</span><span class="hljs-params">(allUsers, activeUsers)</span> {</span>
<span class="hljs-keyword">return</span> allUsers.<span class="hljs-built_in">length</span> - activeUsers.<span class="hljs-built_in">length</span>
}
</code></pre>
</section>
<section id="fp-example" class="slide">
<p>composability!</p>
<pre><code> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">countUsers</span><span class="hljs-params">(users)</span> {</span>
<span class="hljs-keyword">return</span> users.<span class="hljs-built_in">length</span>
}
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">countDeactivatedUsers</span><span class="hljs-params">(allUsers, activeUsers)</span> {</span>
<span class="hljs-keyword">return</span> countUsers(allUsers) - activeUsers.<span class="hljs-built_in">length</span>
}
</code></pre>
</section>
<section id="fp-example" class="slide">
<p>Not Stateless</p>
<pre><code> <span class="hljs-comment">/* Both these functions become statefull */</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">countDeactivatedUsers</span><span class="hljs-params">(allUsers, activeUsers)</span> </span>{
<span class="hljs-keyword">return</span> countUsers(allUsers) - activeUsers.length
}
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">countUsers</span><span class="hljs-params">(users)</span> </span>{
users = localStorage.users
<span class="hljs-keyword">return</span> users.length
}
</code></pre>
</section>
<section id="fp-example" class="slide">
<p>Not Stateless</p>
<pre><code> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">countDeactivatedUsers</span><span class="hljs-params">(allUsers, activeUsers)</span> </span>{
<span class="hljs-keyword">return</span> countUsers(allUsers) - activeUsers.length
}
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">countUsers</span><span class="hljs-params">(users)</span> </span>{
<span class="hljs-comment">/* MUTATION!!! Whatta jerk!! */</span>
users.pop()
<span class="hljs-comment">/* cover up */</span>
<span class="hljs-keyword">return</span> users.length + <span class="hljs-number">1</span>
}
</code></pre>
</section>
<section id="fp-example" class="slide">
<p>Not Stateless</p>
<pre><code> var extras = <span class="hljs-matrix">[]</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">countDeactivatedUsers</span><span class="hljs-params">(allUsers, activeUsers)</span> {</span>
<span class="hljs-keyword">return</span> countUsers(allUsers) - activeUsers.<span class="hljs-built_in">length</span> - extras.<span class="hljs-built_in">length</span>;
}
</code></pre>
</section>
<section id="fp-example" class="slide">
<p>Not Stateless but appears it.</p>
<pre><code> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">countDeactivatedUsers</span><span class="hljs-params">(allUsers, activeUsers)</span> {</span>
localStorage.users = allUsers;
<span class="hljs-keyword">return</span> countUsers(allUsers) - activeUsers.<span class="hljs-built_in">length</span>;
}
</code></pre>
</section>
<section id="flux-problem" class="slide">
<h2>Flux Architecture - The Problem</h2><ul>
<li>The underlying problem is how data flows through applications<ul>
<li>the most basic <strong>dynamic</strong> applications consist of models which hold data, and are responsible for passing data to views</li>
</ul>
</li>
</ul>
<p><img src="https://dl.dropboxusercontent.com/u/13155426/problem_with_mvc_1.png" alt="MVC Issue 1"></p>
</section>
<section id="flux-problem" class="slide">
<ul>
<li>As applications and user actions start to get more complex, views need to update models, and sometimes models need to update models.. and asynchronously at that!</li>
</ul>
<p><img src="https://dl.dropboxusercontent.com/u/13155426/problem_with_mvc_2.png" alt="MVC Issue 2"></p>
</section>
<section id="solution" class="slide">
<h2>The Solution - Unidirectional dataflow</h2><p>Facebook decided to try a new architecture where data flows in one direction, and one direction only (make clever one direction boy band joke)
<img src="https://dl.dropboxusercontent.com/u/13155426/flux_architecture.png" alt="Flux Arch"></p>
</section>
<section id="flux-terms" class="slide">
<h3>Things that make up flux architecture</h3><ul>
<li>Store</li>
<li>View</li>
<li>Actions</li>
<li>Dispatcher</li>
</ul>
</section>
<section id="flux-terms" class="slide">
<h3>What the term??</h3><h4>Action</h4><ul>
<li>Action: an object literal that describes what happened in the view<ul>
<li>Example: {type: 'ADD_TASK', task: 'buy salami'}</li>
</ul>
</li>
</ul>
</section>
<section id="flux-terms-store" class="slide">
<h2>Store</h2><ul>
<li>Store: Holds all the application state and state changing logic<ul>
<li>Over-controlling bureaucrat</li>
<li>All state changes must be made by the store personally</li>
<li>You can't request it to change state (no setters)</li>
<li>To request a state change, you must follow the proper procedures (you must submit an action via the dispatcher)</li>
</ul>
</li>
</ul>
</section>
<section id="flux-term-dispatcher" class="slide">
<h3>Dispatcher</h3><ul>
<li>Dispatcher: basically a big registry of callbacks (Store methods)<ul>
<li>Acts as the operator between the store(s) and action</li>
<li>Kind of like the peanut/beer guy at sporting events<ul>
<li>takes an action, then goes to all the stores and ask who wants the action</li>
</ul>
</li>
</ul>
</li>
</ul>
</section>
<section id="links" class="slide">
<h1>Links</h1><p><a href="https://facebook.github.io/flux/">Facebook's flux page</a></p>
<p><a href="http://redux.js.org">Redux documentation</a></p>
<p><a href="https://github.com/wbuchwalter/ng-redux">NgRedux</a></p>
<p><a href="http://codepen.io/Cspeisman/pen/EPomoN">Flux Counter Example</a></p>
<p><a href="http://codepen.io/Cspeisman/pen/pgpExq">Redux Counter Example</a></p>
</section></div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: Reveal.getQueryHash().transition || 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
//{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
//{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
//{ src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true }
]
});
</script>
<script src="js/dynamic-theme.js"></script><script src="js/custom.js"></script>
</body>
</html>