-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
744 lines (620 loc) · 20.3 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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Fullstack LX - Building web applications with React and Redux</title>
<meta name="description" content="Fullstack LX - Building web applications with React and Redux">
<meta name="author" content="Hakim El Hattab">
<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/black.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
// Live reload
document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] +
':35729/livereload.js?snipver=1"></' + 'script>')
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section >
<img src="https://pbs.twimg.com/profile_images/664837720049623040/35b0aLYT.png" style="border:0px">
<aside class="notes">
Disclaimer: We're not pros, we're starting and exploring
</aside>
</section>
<section>
<section>
<h1> Speakers </h1>
</section>
<section>
<h2> António Novais </h2>
<img src="https://pbs.twimg.com/profile_images/664748856513593345/OG3f2YXc.jpg" style="border:0px" height="248" width="248" />
<p> @acanovais </p>
<p> Redux </p>
</section>
<section>
<h2> Nizar Venturini </h2>
<img src="https://pbs.twimg.com/profile_images/549485382350299137/0-oCONoY.png" style="border:0px" height="248" width="248" />
<p> @trenpixster </p>
<p> React </p>
</section>
<section>
<h2> Rogério Vicente </h2>
<img src="https://pbs.twimg.com/profile_images/378800000656597188/2c57f89fc7114971feb06066fee57e18.jpeg" style="border:0px" height="248" width="248" />
<p> @rogeriopvl </p>
<p> React+Redux </p>
</section>
</section>
<section>
<section data-background="http://blog.addthiscdn.com/wp-content/uploads/2014/11/addthis-react-flux-javascript-scaling.png">
</section>
<section>
<h2>But why?</h2>
<aside class="notes">
let's step back in time
</aside>
</section>
<section data-background="http://i.giphy.com/hn45V8hBhRIpW.gif">
<h2>First, let's step back in time</h2>
<p class="fragment">(Redux wink wink)</p>
<aside class="notes">
At first, jquery
</aside>
</section>
<section data-background="#ADAD00">
<h1 style="color:#333">jQuery era</h1>
<ul>
<li class="fragment">Click binds everywhere</li>
<li class="fragment">DOM pollution</li>
<li class="fragment">Global scope selectors</li>
<li class="fragment"><code class="highlight">$(children).parent.parent.children</code> </li>
<li class="fragment">Mutation</li>
<li class="fragment">Mutation everywhere!</li>
</ul>
<aside class="notes">
Click binds everywhere
DOM pollution
Global scope selectors
code class="highlight">$(children).parent.parent.children</code>
Mutation
Mutation everywhere!
----
some disagreements on mutation
</aside>
</section>
<section>
<center>
<blockquote class="fragment twitter-tweet" lang="en"><p lang="en" dir="ltr">Make JavaScript More Mutable.</p>— Trump on JavaScript (@realDonaldJS) <a href="https://twitter.com/realDonaldJS/status/664540678836195328">November 11, 2015</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
</center>
<aside class="notes">
What problems did all this bring?
</aside>
</section>
<section>
<h1>So what?</h1>
<ul>
<li>Refactoring was hedious</li>
<li>No structure/code architecture</li>
<li>Click baiting</li>
<li>All those memory leaks</li>
<li>SPA?<p class="fragment"> Good luck!</p></li>
</ul>
<aside class="notes">
Refactoring was hedious
No structure/code architecture
Click baiting
All those memory leaks
SPA? Good luck
Our super savior, MV* era
</aside>
</section>
<section data-background="http://i.giphy.com/rzspAaesd8ltm.gif">
<h1 style="color:#333">MV* Era</h1>
</section>
<section>
<h1>Improvements!</h1>
<ul>
<li class="fragment">Structure...ish</li>
<li class="fragment">Model definition</li>
<li class="fragment">View definition</li>
<li class="fragment">Scoped selectors</li>
<li class="fragment">Bindings</li>
</ul>
<aside class="notes">
Structure...ish
Model definition
View definition
Scoped selectors
Bindings
Yet...
</aside>
</section>
<section data-background="http://i.giphy.com/PXclV9NHnqhQA.gif">
<h1>Yet... Bindings Hell</h1>
</section>
<section data-background="http://firstdoit.com/content/images/2015/05/mvc_dep_hell.png">
<aside class="notes">
From Facebook's presentation video
ENTER REACT
</aside>
</section>
<section>
<h1>Enter React!</h1>
<p class="fragment">A new paradigm emerged</p>
<p class="fragment">Not a framework</p>
<aside class="notes">
A new paradigm emerged
BTW, not a framework, "just" the V
</aside>
</section>
<section>
<h1>Functional Programming</h1>
<p class="fragment">Wat?</p>
<aside class="notes">
Really?
</aside>
</section>
<section data-background="http://i221.photobucket.com/albums/dd87/OneWingedRoxas/orlyquitevh4.jpg">
<h1 style="margin-top:60%;color:#333">Quite Rly</h1>
</section>
<section>
<p>"Entra porco, sai salsicha"</p>
<p class="fragment"><i>Insert a pig, get a sausage</i></p>
<pre style="margin-left:40%;width:20%">
<code data-trim>
f(A) => B
f(A) => B
(...)
f(A) => B
</code>
</pre>
<aside class="notes">
No matter how many times you run it, it gives the same result
</aside>
</section>
<section data-transition="fade">
<h3>Functional approach to DOM composition</h3>
<pre data-trim><code>
<div>
<h3>OMG PONIES</h3>
</div>
</code></pre>
<p> </p>
<p> </p>
<aside class="notes">
This compiles to Javascript code
</aside>
</section>
<section data-transition="fade">
<h3>Functional approach to DOM composition</h3>
<pre data-trim><code>
React.createElement(
'div',
null,
React.createElement(
'h3',
null,
'OMG PONIES'
)
);
</code></pre>
<p class="fragment">Composable</p>
<p class="fragment">Declarative</p>
<aside class="notes">
Composable
Declarative
</aside>
</section>
<section>
<h3>Let it sink</h3>
<pre data-trim><code>
<div>
<h3>OMG PONIES</h3>
</div>
</code></pre>
<aside class="notes">
The DOM elements are code
Another awesome feature: Virtual DOM
</aside>
</section>
<section>
<h1>Virtual DOM</h1>
<img src="http://techblog.constantcontact.com/wp-content/uploads/2014/11/TechTalk_BAnderson_11052014_Image7.png">
<aside class="notes">
We'll show you some code which uses
</aside>
</section>
<section>
<p>ES6</p>
<p>JSX</p>
<p>Babel</p>
<p class="fragment">github.com/Talkdesk/react-redux-boilerplate</p>
<aside class="notes">
we made a repo public where you can play around with everything we're presenting
</aside>
</section>
<section data-background="http://i.giphy.com/y8Mz1yj13s3kI.gif">
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<h1>Sharing is caring</h1>
<aside class="notes">
Enough of slides!
</aside>
</section>
<section>
<h1>coding time!</h1>
</section>
<section data-background="http://i.giphy.com/12KiGLydHEdak8.gif">
</section>
<section data-background="http://i.giphy.com/EdzcJPoDaaqaY.gif">
<h3>Thanks</h3>
</section>
</section>
<section>
<section>
<h1>Redux</h1>
</section>
<section>
<h2>A predictable state container for Javascript Apps</h2>
<p class="fragment">What does that mean?</p>
</section>
<section>
<h3> ¯\_(ツ)_/¯ </h3>
</section>
<section data-background="http://i.giphy.com/5gUnOrltPvZzW.gif">
<h2>A little bit of history...</h2>
</section>
<section>
<h2>Developing Big Apps</h2>
<br/>
<p class="fragment">Dependency Hell</p>
<p class="fragment">Hard to <b>predict</b> effects of a change</p>
<p class="fragment">Hard to trace data flow</p>
<p class="fragment">Slow development lifecycle</p>
<p class="fragment">Takes forever to test things and reproduce state</p>
<p class="fragment">The list goes on ...</p>
</section>
<section data-background="http://i.giphy.com/EtB1yylKGGAUg.gif">
<h2>Frustration</h2>
</section>
<section>
<h2>Flux</h2>
<p>Facebook's pattern for data flow</p>
<img class="fragment" src="https://facebook.github.io/flux/img/flux-simple-f8-diagram-with-client-action-1300w.png" height="300" width="1000" />
<aside class="notes">
</aside>
</section>
<section>
<img src="https://facebook.github.io/flux/img/flux-simple-f8-diagram-with-client-action-1300w.png" height="300" width="1000" />
<ul>
<li> Single directional data flow </li>
<li> Actions are just plain Javascript objects </li>
<li> A single dispatcher that sends actions to the stores </li>
<li> Stores contain the state and change their state </li>
<li> Stores tell the views to re-render </li>
<li> Views can create new actions </li>
</ul>
</section>
<section>
<h2> Does this solve all our frustrations ? </h2>
</section>
<section data-background="http://i.giphy.com/kX5tZqZWyKxMI.gif">
</section>
<section>
<h2> In comes Dan Abramov </h2>
<img src="https://pbs.twimg.com/profile_images/553711083064541184/9VsY9i09_400x400.jpeg" height="248" width="248" />
<h3> Goal </h3>
<p> Hot reload </p>
<p> Time travelling </p>
<aside class="notes">
- Do you know why Hot reload while maintaining state is difficult with flux pattern?
- Stores contain state and if you want to change a store to change behaviour you lose the state
- What about time travelling?
- It is the ability to reproduce a previous state of the app
- By having all these different stores you never have a vision of the whole state of the app
</aside>
</section>
<section>
<h2> Redux was born! </h2>
<p class="fragment"> Single store </p>
<p class="fragment"> Reducers </p>
<br/>
<p class="fragment"> Welcomme FP to JS Apps </p>
<aside class="notes">
- A single store that contains the whole state of the App and is only a container. No logic
- Reducers that are pure functions that receive a state and an action and return a new state
</aside>
</section>
<section>
<h3> Single store </h3>
<ul>
<li> Contains the whole state of the App </li>
<li> Has no business logic </li>
<li> Is only a container </li>
</ul>
</section>
<section>
<h3> Reducers </h3>
<ul>
<li> Pure functions </li>
<li> Receive a state and an action </li>
<li> Return a new state </li>
</ul>
</section>
<section data-background="http://i.giphy.com/zXmbOaTpbY6mA.gif">
<h2> Let's look at some code! </h2>
</section>
<section>
<h2> Actions </h2>
<pre>
<code>
export const INCREMENT_COUNTER = 'INCREMENT_COUNTER';
export const DECREMENT_COUNTER = 'DECREMENT_COUNTER';
export function increment(value) {
return {
type: INCREMENT_COUNTER,
value
};
}
export function decrement(value) {
return {
type: DECREMENT_COUNTER,
value
};
}
</code>
</pre>
</section>
<section>
<h2> Reducers </h2>
<pre>
<code>
import { INCREMENT_COUNTER, DECREMENT_COUNTER } from '../actions';
export default function counter(state = 0, action) {
switch (action.type) {
case INCREMENT_COUNTER:
return state + action.value;
case DECREMENT_COUNTER:
return state - action.value;
default:
return state;
}
}
</code>
</pre>
</section>
<section>
<h2>A predictable state container for Javascript Apps</h2>
<p class="fragment">What does that mean?</p>
</section>
<section>
<p class="fragment"> How the hell can I do something real with just this? </h2>
<p class="fragment"> What about side effects? </p>
<p class="fragment"> Did this solve our frustrations? </p>
<p class="fragment"> There is always something more ... </p>
</section>
<section>
<h2>Middlewares</h2>
<p class="fragment"> Before actions get to the reducers </p>
<p class="fragment"> Have acess to the action and the store </p>
<br/>
<p class="fragment"> Add side effects to the actions </p>
<p class="fragment"> Flow control </p>
<p class="fragment"> Tooling </p>
</section>
<section>
<h2>Middlewares</h2>
<pre>
<code>
const logger = store => next => action => {
console.log('dispatching', action)
let result = next(action)
console.log('next state', store.getState())
return result
}
</code>
</pre>
</section>
<section>
<h2>Middlewares</h2>
<pre>
<code>
const recorder = store => next => action => {
let result = next(action)
let history = JSON.parse(localStorage.getItem('history'))
history.push({
action
state: store.getState()
})
localStorage.setItem('history', JSON.stringify(history));
return result
}
</code>
</pre>
</section>
<section data-background="http://i.giphy.com/PWATmSnHLCC1a.gif">
<h1>Goodies!</h1>
</section>
<section>
<h2>Thunk middleware</h2>
<p> Having async actions </p>
<pre>
<code>
export function incrementAsync(delay = 1000) {
return dispatch => {
setTimeout(() => {
dispatch(increment(1));
}, delay);
}
}
</code>
</pre>
</section>
<section>
<h2>Thunk middleware</h2>
<p> Actions that execute in certain conditions </p>
<pre>
<code>
export function incrementIfOdd() {
return (dispatch, getState) => {
const { counter } = getState();
if (counter % 2 === 0) {
return;
}
dispatch(increment(1));
};
}
</code>
</pre>
</section>
<section>
<h2>Thunk middleware</h2>
<p> Async actions and promises </p>
<pre>
<code>
export function fetchGuests(event) {
return function (dispatch) {
dispatch({
type: REQUEST_GUESTS,
event
});
return fetch(`http://www.meetup.com/${event}`)
.then(response => dispatch({
type: RECEIVE_GUESTS,
reponse: json
}),
error => dispatch({
type: ERROR_GUESTS,
error
}));
}
}
</code>
</pre>
</section>
<section>
<h2> How does this influence React ? </h2>
<img class="fragment" width="640" height="480" src="http://i.giphy.com/9HsuhCHWWKc8M.gif" />
</section>
<section>
<h2> Redux + React </h2>
<img src="http://i3.kym-cdn.com/entries/icons/original/000/007/582/tumblr_lmputme3co1qa6q7k_large.png" />
<p> Redux store passes the whole state to the root component </p>
<p> All other components re-render themselves </p>
<p> But should they always re-render ? (wink wink Immutable.js) </p>
</section>
<section>
<h2> Redux + React </h2>
<table>
<thead>
<tr>
<th>Smart Components</th>
<th>Dumb Components</th>
</tr>
</thead>
<tbody>
<tr>
<td>Top level components </td>
<td>Middle and leaf components </td>
</tr>
<tr>
<td>Connected to redux</td>
<td>Unanware of redux</td>
</tr>
<tr>
<td>Subscribes to redux state</td>
<td>Reads data from props</td>
</tr>
<tr>
<td>Dispatch actions into redux</td>
<td>Invoke callbacks from props</td>
</tr>
</tbody>
</table>
</section>
<section data-background="http://i.giphy.com/EdzcJPoDaaqaY.gif">
<h3>Thank you!</h3>
</section>
</section>
<section>
<section>
<h1>Let's live code a web application!</h1>
</section>
<section data-background="http://media.giphy.com/media/ceHKRKMR6Ojao/giphy.gif">
</section>
<section>
<h3>Our own prize raffle app!</h3>
</section>
<section>
<h3>But first, let's plan all the things!</h3>
</section>
<section>
<h3>The State</h3>
<img style="width: 600px" src="https://cld.pt/dl/download/69a1323c-3e43-4db7-bf24-4b8cca3bc644/appstate.png">
</section>
<section>
<h3>The Components?</h3>
</section>
<section>
<h3>App</h3>
<h3 class="fragment">StartButton</h3>
<h3 class="fragment">CandidateGrid</h3>
<h3 class="fragment">PickButton</h3>
<h3 class="fragment">WinnersList</h3>
<h3 class="fragment">UserCard</h3>
<h3 class="fragment">UserAvatar</h3>
</section>
<section data-background="http://media.giphy.com/media/Z0dvuZszc3r3i/giphy.gif">
</section>
</section>
<section>
<h1>Thanks!</h1>
<div class="fragment">
<h3>And special thanks to Talkdesk</h3>
<h3>for providing all the goodies <3</h3>
</div>
</section>
</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: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'http://lab.hakim.se/reveal-js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'http://lab.hakim.se/reveal-js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'http://lab.hakim.se/reveal-js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'http://lab.hakim.se/reveal-js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'http://lab.hakim.se/reveal-js/plugin/zoom-js/zoom.js', async: true },
{ src: 'http://lab.hakim.se/reveal-js/plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>