Slide 1

Slide 1 text

What’s Redux Anyway?

Slide 2

Slide 2 text

Giorgio Polvara

Slide 3

Slide 3 text

Giorgio Polvara

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

“React is a JavaScript library for creating user interfaces by Facebook and Instagram. Many people choose to think of React as the V in MVC.”

Slide 6

Slide 6 text

The V in MVC

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

¯\_(ϑ)_/¯

Slide 9

Slide 9 text

Flux

Slide 10

Slide 10 text

“Flux is the application architecture that Facebook uses for building client-side web applications. It complements React's composable view components by utilizing a unidirectional data flow. It's more of a pattern rather than a formal framework, and you can start using Flux immediately without a lot of new code.”

Slide 11

Slide 11 text

+

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Alt

Slide 14

Slide 14 text

Alt Reflux

Slide 15

Slide 15 text

Alt Reflux Fluxible

Slide 16

Slide 16 text

Alt Reflux Flummox Fluxible

Slide 17

Slide 17 text

Alt Reflux Flummox Fluxible Fluxxor

Slide 18

Slide 18 text

Alt Reflux Flummox Fluxible Fluxxor Fluxify

Slide 19

Slide 19 text

Alt Reflux Flummox Fluxible Fluxxor Fynx Fluxify

Slide 20

Slide 20 text

Alt Reflux Flummox Fluxible Fluxxor marty.js Fynx Fluxify

Slide 21

Slide 21 text

Alt Reflux Flummox Fluxible Fluxxor marty.js Fynx Delorean Fluxify

Slide 22

Slide 22 text

Alt Reflux Flummox Fluxible Fluxxor marty.js Fynx McFly Delorean Fluxify

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Dan Abramov

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

MVC

Slide 32

Slide 32 text

MVC

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

author

Slide 40

Slide 40 text

author name

Slide 41

Slide 41 text

author name handler

Slide 42

Slide 42 text

author name handler photo

Slide 43

Slide 43 text

author name handler isFollowing photo

Slide 44

Slide 44 text

author name handler text photo isFollowing

Slide 45

Slide 45 text

author name handler text retweets photo isFollowing

Slide 46

Slide 46 text

author name handler text retweets likes photo isFollowing

Slide 47

Slide 47 text

author name handler text retweets likes photo likePhotos isFollowing

Slide 48

Slide 48 text

author name handler text retweets likes timestamp photo likePhotos isFollowing

Slide 49

Slide 49 text

author name handler text retweets likes timestamp photo likePhotos isFollowing

Slide 50

Slide 50 text

author name handler text retweets likes timestamp { } photo likePhotos isFollowing

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

No content

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

{ … }

Slide 58

Slide 58 text

State

Slide 59

Slide 59 text

Store

Slide 60

Slide 60 text

import { createStore } from 'redux' const store = createStore(...)

Slide 61

Slide 61 text

store.getState() store.subscribe(function () { console.log(store.getState()) })

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

Store

Slide 66

Slide 66 text

State Store

Slide 67

Slide 67 text

State Store

Slide 68

Slide 68 text

State Store

Slide 69

Slide 69 text

State Store

Slide 70

Slide 70 text

State Store

Slide 71

Slide 71 text

const Root = () => ( ) AppRegistry .registerComponent("App", () => Root)

Slide 72

Slide 72 text

import { Provider } from 'react-redux/native' const Root = () => ( ) AppRegistry .registerComponent("App", () => Root)

Slide 73

Slide 73 text

import { Provider } from 'react-redux/native' const Root = () => ( ) AppRegistry .registerComponent("App", () => Root)

Slide 74

Slide 74 text

class App extends Component {} export default App

Slide 75

Slide 75 text

import { connect } from 'react-redux'
 class App extends Component {} export default App

Slide 76

Slide 76 text

import { connect } from 'react-redux'
 class App extends Component {} export default connect()(App)

Slide 77

Slide 77 text

State Store

Slide 78

Slide 78 text

State Store

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

State Store

Slide 82

Slide 82 text

State Store Action

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

{ }

Slide 85

Slide 85 text

{ type: '...' }

Slide 86

Slide 86 text

{ type: 'LOGOUT' }

Slide 87

Slide 87 text

{ type: '...', payload: ... }

Slide 88

Slide 88 text

{ type: 'LIKE_TWEET', payload: tweetId }

Slide 89

Slide 89 text

{ type: 'CREATE_TWEET', payload: text }

Slide 90

Slide 90 text

{ type: 'ADD_POST', payload: { text: ..., author: ... tags: [...] } }

Slide 91

Slide 91 text

{ type: 'LIKE_TWEET', payload: tweetId }

Slide 92

Slide 92 text

function likeTweet (tweetId) { { type: 'LIKE_TWEET', payload: tweetId } }

Slide 93

Slide 93 text

function likeTweet (tweetId) { return { type: 'LIKE_TWEET', payload: tweetId } }

Slide 94

Slide 94 text

function likeTweet (tweetId) { return { type: 'LIKE_TWEET', payload: tweetId } } const action = likeTweet(1)

Slide 95

Slide 95 text

State Store Action

Slide 96

Slide 96 text

store.getState() store.subscribe(...)

Slide 97

Slide 97 text

store.getState() store.subscribe(...) store.dispatch(action)

Slide 98

Slide 98 text

State Store Action

Slide 99

Slide 99 text

Reducers

Slide 100

Slide 100 text

function(state, action) => nextState

Slide 101

Slide 101 text

function(state, action) => nextState

Slide 102

Slide 102 text

function(state, action) => nextState

Slide 103

Slide 103 text

function(state, action) => nextState

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

{ count: 85 }

Slide 107

Slide 107 text

{ count: 85 } { type: 'INCREMENT' } { type: 'DECREMENT' }

Slide 108

Slide 108 text

const reducer = (state, action) => { switch(action.type) { case 'INCREMENT': return {total: state.total + 1 } case 'DECREMENT': return {total: state.total - 1 } default: return state } }

Slide 109

Slide 109 text

const reducer = (state, action) => { switch(action.type) { case 'INCREMENT': return {total: state.total + 1 } case 'DECREMENT': return {total: state.total - 1 } default: return state } }

Slide 110

Slide 110 text

const reducer = (state, action) => { switch(action.type) { case 'INCREMENT': return { count: state.count + 1 } case 'DECREMENT': return {total: state.total - 1 } default: return state } }

Slide 111

Slide 111 text

const reducer = (state, action) => { switch(action.type) { case 'INCREMENT': return { count: state.count + 1 } case 'DECREMENT': return { count: state.count - 1 } default: return state } }

Slide 112

Slide 112 text

const reducer = (state, action) => { switch(action.type) { case 'INCREMENT': return { count: state.count + 1 } case 'DECREMENT': return { count: state.count - 1 } default: return state } }

Slide 113

Slide 113 text

import { createStore } from 'redux' const store = createStore(...)

Slide 114

Slide 114 text

import { createStore } from 'redux' const store = createStore(reducer)

Slide 115

Slide 115 text

State Store Action

Slide 116

Slide 116 text

State Store Action

Slide 117

Slide 117 text

State Store Action

Slide 118

Slide 118 text

State Store Action

Slide 119

Slide 119 text

State Store Action

Slide 120

Slide 120 text

State Store Action

Slide 121

Slide 121 text

State Store Action

Slide 122

Slide 122 text

State State Store Action

Slide 123

Slide 123 text

State State Store Action

Slide 124

Slide 124 text

State State Store Action

Slide 125

Slide 125 text

State State Store Action

Slide 126

Slide 126 text

State State Store Action Unidirectional Data Cycle

Slide 127

Slide 127 text

Demo Time!

Slide 128

Slide 128 text

State Store Action

Slide 129

Slide 129 text

Where to go from here?

Slide 130

Slide 130 text

Where to go from here? Create small Redux apps

Slide 131

Slide 131 text

Where to go from here? Create small Redux apps Check combineReducers

Slide 132

Slide 132 text

Where to go from here? Create small Redux apps Async actions with thunks Check combineReducers

Slide 133

Slide 133 text

Where to go from here? Create small Redux apps Check combineReducers Async actions with thunks …

Slide 134

Slide 134 text

Thank You Giorgio Polvara @gpx