SlideShare a Scribd company logo
MANAGE THE FLUX OF
YOUR WEB APPLICATION:
LET’S REDUX
Redux
Ego Slide
f.strazzullo@extrategy.net
@TheStrazz86
https://github.com/francesco-strazzullo
https://medium.com/@TheStrazz86
https://slides.com/francescostrazzullo
http://codingjam.it/
https://taskomat.tech/it/
State Management
React
“ A JavaScript library for
building user interfaces
Manage the Flux of your Web Application: Let's Redux
class HelloMessage extends React.Component {
render() {
return <div>Hello {this.props.name}!</div>;
}
}
ReactDOM.render(<HelloMessage name="World" />, mountNode);
So Basically...it's not a
framework
Features
Components
JSX
class HelloMessage extends React.Component {
render() {
return React.createElement(
"div",
null,
"Hello ",
this.props.name
);
}
}
ReactDOM.render(React.createElement(HelloMessage, { name: "World" }), mountNode);
Virtual Dom
State
class Timer extends React.Component {
constructor(props) {
super(props);
this.state = {secondsElapsed: 0};
}
tick() {
this.setState((prevState) => ({
secondsElapsed: prevState.secondsElapsed + 1
}));
}
componentDidMount() {
this.interval = setInterval(() => this.tick(), 1000);
}
componentWillUnmount() {
clearInterval(this.interval);
}
render() {
return (
<div>Seconds Elapsed: {this.state.secondsElapsed}</div>
);
}
}
ReactDOM.render(<Timer />, mountNode);
Manage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's Redux
Flux
“ Application Architecture For
Building User Interfaces
Why Not MVC?
Manage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's Redux
Manage the Flux of your Web Application: Let's Redux
Action: an event fired in the
system with the purpose to
change its state
Dispatcher: an event bus to
send actions into the system
Store: business logic objects.
Just like the M in MVC
View: React Components
Manage the Flux of your Web Application: Let's Redux
Why Flux?
One Way of Thinking
Constant complexity on big
projects
Redux
“ Redux is a predictable state
container for JavaScript apps
Why not Flux?
One Way of Thinking (Really?)
Principles
"Single source of truth"
The state of your whole application is stored in
an object tree inside a single store.
"State is read-only"
The only way to mutate the state is to emit an
action, an object describing what happened.
"Mutations are written
as pure functions"
To specify how the state tree is transformed by
actions, you write pure reducers.
Elements
Actions
import Dispatcher from "src/Dispatcher";
var add = function(text) {
Dispatcher.dispatch({
actionType: "addTodo",
text: text
});
};
var add = function(text) {
return {
actionType: "addTodo",
text: text
};
};
Flux Redux
Reducer
function addTodo(state,text){
var toReturn = Object.assign({},state,{
todos:[...state.todos]
});
toReturn.todos.push(text);
return toReturn;
};
Store + Dispatcher
import { createStore } from 'redux';
import Reducers from 'src/Reducers';
let store = createStore(Reducers);
Container Components
Presentational Components
Why Redux?
One Way of Thinking (Really
this time)
Serilizable State
No side-effect
No Technical Debt
Manage the Flux of your Web Application: Let's Redux
Async Actions
onClick() {
this.props.dispatch(actions.requestData())
this.api.list().then(response => {
this.props.dispatch(actions.requestDataSuccess(response.data))
}).catch(error => {
this.props.dispatch(actions.requestDataError(error))
})
}
redux-saga
“ A Saga is an independent
component that reacts to
domain events in a cross-
aggregate, eventually
consistent manner.
“ redux-saga is a library that
aims to make side effects in
Redux applications easier and
better.
function* fetch() {
try {
const data = yield call(api.list);
yield put(actions.requestDataSuccess(data));
} catch (e) {
yield put(actions.requestDataError(e));
}
}
function* mySaga() {
yield takeLatest("REQUEST_DATA", fetch);
}
export default mySaga;
Manage the Flux of your Web Application: Let's Redux
That's It!
f.strazzullo@e-xtrategy.net
@TheStrazz86
https://github.com/e-xtrategy/javascript-course/
Thanks!

More Related Content

PPTX
Redux training
PDF
React state managmenet with Redux
PDF
React & Redux
PDF
React redux
PPTX
React with Redux
PPTX
Introduction to react and redux
PDF
Intro to Redux | DreamLab Academy #3
PDF
React&redux
Redux training
React state managmenet with Redux
React & Redux
React redux
React with Redux
Introduction to react and redux
Intro to Redux | DreamLab Academy #3
React&redux

What's hot (20)

PDF
React + Redux. Best practices
PPTX
PDF
React, Redux, ES2015 by Max Petruck
PDF
Designing applications with Redux
PDF
Introduction to Redux
PDF
Switch to React.js from AngularJS developer
PDF
State Models for React with Redux
PDF
React.js or why DOM finally makes sense
PDF
Angular redux
PDF
Let's discover React and Redux with TypeScript
PPTX
Better React state management with Redux
PDF
Workshop 20: ReactJS Part II Flux Pattern & Redux
PPTX
React + Redux + TypeScript === ♥
PDF
React lecture
PPTX
ProvJS: Six Months of ReactJS and Redux
PDF
Introduction to React & Redux
PDF
React Lifecycle and Reconciliation
PDF
Advanced redux
PDF
Using React, Redux and Saga with Lottoland APIs
PDF
Creating a WYSIWYG Editor with React
React + Redux. Best practices
React, Redux, ES2015 by Max Petruck
Designing applications with Redux
Introduction to Redux
Switch to React.js from AngularJS developer
State Models for React with Redux
React.js or why DOM finally makes sense
Angular redux
Let's discover React and Redux with TypeScript
Better React state management with Redux
Workshop 20: ReactJS Part II Flux Pattern & Redux
React + Redux + TypeScript === ♥
React lecture
ProvJS: Six Months of ReactJS and Redux
Introduction to React & Redux
React Lifecycle and Reconciliation
Advanced redux
Using React, Redux and Saga with Lottoland APIs
Creating a WYSIWYG Editor with React
Ad

Similar to Manage the Flux of your Web Application: Let's Redux (20)

PDF
Reactивная тяга
PPTX
React outbox
PPTX
Introduction to React JS for beginners
PPTX
React/Redux
PDF
The evolution of redux action creators
PPTX
Introduction to React and MobX
PPTX
PDF
Egghead redux-cheat-sheet-3-2-1
PDF
How to use redux with react hooks in react native application
PDF
Materi Modern React Redux Power Point.pdf
PPTX
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
PDF
A full introductory guide to React
PDF
Learning React: Facebook's Javascript Library For Building User Interfaces
PDF
Stay with React.js in 2020
PPTX
React - An Introduction
PPTX
Building user interface with react
PDF
React.js workshop by tech47.in
PDF
Intro to React | DreamLab Academy
PPTX
Combining Angular and React Together
PDF
React 101
Reactивная тяга
React outbox
Introduction to React JS for beginners
React/Redux
The evolution of redux action creators
Introduction to React and MobX
Egghead redux-cheat-sheet-3-2-1
How to use redux with react hooks in react native application
Materi Modern React Redux Power Point.pdf
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
A full introductory guide to React
Learning React: Facebook's Javascript Library For Building User Interfaces
Stay with React.js in 2020
React - An Introduction
Building user interface with react
React.js workshop by tech47.in
Intro to React | DreamLab Academy
Combining Angular and React Together
React 101
Ad

More from Commit University (20)

PDF
Accessibilità ed equità digitale: un impegno, non una scelta
PDF
GitHub Copilot:vediamo chi comanda - Commit University.pdf
PDF
Contract Driven Development - Branch 2024.pdf
PPTX
Cybersecurity & AI: Illusioni e Speranze
PDF
Migliorare la Developer Experience in un mondo Cloud Native
PPTX
Scopri come sfruttare la potenza della Hybrid RAG
PDF
Introduzione a AWS Forecast e SageMaker DeepAR: Prevedere la Domanda con il M...
PDF
Oltre l'hype: vulnerabilità e limiti dell'intelligenza artificiale.pdf
PPTX
Alla scoperta dei Vector Database e dei RAG
PDF
Nell’iperspazio con Rocket: il Framework Web di Rust!
PDF
Crea il tuo assistente AI con lo Stregatto (open source python framework)
PDF
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
PDF
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
PDF
Slide-10years.pdf
PDF
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
PDF
Vue.js slots.pdf
PPTX
Commit - Qwik il framework che ti stupirà.pptx
PPTX
Sviluppare da zero una Angular Web App per la PA
PDF
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
PDF
Prisma the ORM that node was waiting for
Accessibilità ed equità digitale: un impegno, non una scelta
GitHub Copilot:vediamo chi comanda - Commit University.pdf
Contract Driven Development - Branch 2024.pdf
Cybersecurity & AI: Illusioni e Speranze
Migliorare la Developer Experience in un mondo Cloud Native
Scopri come sfruttare la potenza della Hybrid RAG
Introduzione a AWS Forecast e SageMaker DeepAR: Prevedere la Domanda con il M...
Oltre l'hype: vulnerabilità e limiti dell'intelligenza artificiale.pdf
Alla scoperta dei Vector Database e dei RAG
Nell’iperspazio con Rocket: il Framework Web di Rust!
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Slide-10years.pdf
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Vue.js slots.pdf
Commit - Qwik il framework che ti stupirà.pptx
Sviluppare da zero una Angular Web App per la PA
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Prisma the ORM that node was waiting for

Recently uploaded (20)

PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
Teaching material agriculture food technology
PDF
KodekX | Application Modernization Development
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Modernizing your data center with Dell and AMD
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Advanced methodologies resolving dimensionality complications for autism neur...
Teaching material agriculture food technology
KodekX | Application Modernization Development
Building Integrated photovoltaic BIPV_UPV.pdf
A Presentation on Artificial Intelligence
Unlocking AI with Model Context Protocol (MCP)
“AI and Expert System Decision Support & Business Intelligence Systems”
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Modernizing your data center with Dell and AMD
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf

Manage the Flux of your Web Application: Let's Redux