SlideShare una empresa de Scribd logo
1 de 53
Descargar para leer sin conexión
THINKING
IN REDUX
Nir Kaufman
Patterns & techniques
@nirkaufman
Google Developer Expert for Web tech
Principal FE developer at 500Tech
Community addicted
Nir Kaufman
1997
CD-ROM Included !
https://goo.gl/ZcpHZt
CQSCommand Query Separation
Command–query separation (CQS)
Every method should either be
a command that performs an action,
or a query that returns data to the
caller, but not both
- Meyer, Bertrand.
Command–query separation (CQS)
Every method should either be
a command that performs an action,
or a query that returns data to the
caller, but not both.
- Meyer, Bertrand.
Command–query separation (CQS)
Asking a question
should not change the answer.
“
- Meyer, Bertrand.
Command–query separation (CQS)
Commands
Change the state of a system,
but do not return a value.
- Martin Fowler.
Command–query separation (CQS)
Commands
Change the state of a system,
but do not return a value.
- Martin Fowler.
Command–query separation (CQS)
Queries
Return a result and do not change
the observable state of the system.
- Martin Fowler.
Command–query separation (CQS)
Queries
Return a result and do not change
the observable state of the system.
- Martin Fowler.
Command–query separation (CQS)
Dispatcher StateCommands
Queries
Redux
UI StoreActions
Selectors
CQS & Redux
Separate methods that change
state from those that don't. 
2003
https://goo.gl/ZcpHZt
65 Messaging Patterns
Enter Redux
Redux is a front-end oriented
Lean implementation of a
messaging system.
Redux Store
UI
Middleware
Reducers
Action
Creators
Selectors
View
Action
Action
State
It’s all about
Action processing.
ACTION IN ACTION OUT
Middleware Reducers
Action
Creators
Action Action
State
Programming with Actions
Command Event Document
Command Event Document
Ask for something
Command Event Document
Something happened
Command Event Document
Write data to the state
FETCH_BOOKS
API_REQUEST
SET_LOADER
API_SUCCESS
API_ERROR
SET_LOADER
SET_BOOKS
SET_LOADER
SET_NOTIFICATION
FETCH_BOOKS API_REQUEST
API_SUCCESS
API_ERROR
SET_LOADER
SET_LOADER
SET_LOADER
SET_BOOKS
SET_NOTIFICATION
Action Types
1
Action Creators
2
Reducers
3
FETCH_BOOKS API_REQUEST
API_SUCCESS
API_ERROR
SET_LOADER
SET_LOADER
SET_LOADER
SET_BOOKS
SET_NOTIFICATION
From Command to Document
The Middleware
Action processing patterns
Middleware
Redux flow
Middleware Reducers
Action
Creators
State
Filter Map Split
Enrich Normalize TranslateCompose
Actions Processing Patterns
Aggregate
Two types of middleware
Core Application
Generic and reusable Describe a specific flow
Single Responsibility Principal
FETCH_BOOKS API_REQUEST
API_SUCCESS
API_ERROR
SET_LOADER
SET_LOADER
SET_LOADER
SET_BOOKS
SET_NOTIFICATION
The Books Middleware
FETCH_BOOKS API_REQUEST SET_LOADER
Filter & Split
The API Middleware
API_REQUEST
API_SUCSSES
API_ERROR
API_ON_PROGRESS
Filter & Map
Complete the flow
API_SUCCESS (books) SET_BOOKS SET_LOADER
API_ERROR (books) SET_NOTIFICATION SET_LOADER
Split
Filter Map Split
Action Routing Patterns
K K K
Integrity Key
The Multi Middleware
dispatch
The Logger Middleware
REACT_APP_ENV
Action Transformation Patterns
context & content
Enrich Normalize
Our Core Middleware Pipe
multi
api
logger
The Normalize Middleware
content transform
SET_BOOKS SET_BOOKS NORMALIZE
Summary
Redux is a front-end oriented
Lean implementation of a
messaging system.
Programming with Actions
Supporting Libraries
A practical functional library
for JavaScript
An API for async programming with
observable streams
Recommended reading
My book
Thank you!

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Workshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & ReduxWorkshop 20: ReactJS Part II Flux Pattern & Redux
Workshop 20: ReactJS Part II Flux Pattern & Redux
 
Ngrx
NgrxNgrx
Ngrx
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS Introduction
 
Modern Web Developement
Modern Web DevelopementModern Web Developement
Modern Web Developement
 
React + Redux. Best practices
React + Redux.  Best practicesReact + Redux.  Best practices
React + Redux. Best practices
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 
Introduction to Redux (for Angular and React devs)
Introduction to Redux (for Angular and React devs)Introduction to Redux (for Angular and React devs)
Introduction to Redux (for Angular and React devs)
 
Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3 Intro to Redux | DreamLab Academy #3
Intro to Redux | DreamLab Academy #3
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and Redux
 
Introduction to React & Redux
Introduction to React & ReduxIntroduction to React & Redux
Introduction to React & Redux
 
Workshop 17: EmberJS parte II
Workshop 17: EmberJS parte IIWorkshop 17: EmberJS parte II
Workshop 17: EmberJS parte II
 
React state management with Redux and MobX
React state management with Redux and MobXReact state management with Redux and MobX
React state management with Redux and MobX
 
Creating a WYSIWYG Editor with React
Creating a WYSIWYG Editor with ReactCreating a WYSIWYG Editor with React
Creating a WYSIWYG Editor with React
 
Ngrx: Redux in angular
Ngrx: Redux in angularNgrx: Redux in angular
Ngrx: Redux in angular
 
Workshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte IIWorkshop 13: AngularJS Parte II
Workshop 13: AngularJS Parte II
 
Using React, Redux and Saga with Lottoland APIs
Using React, Redux and Saga with Lottoland APIsUsing React, Redux and Saga with Lottoland APIs
Using React, Redux and Saga with Lottoland APIs
 
React & Redux
React & ReduxReact & Redux
React & Redux
 
Inversion Of Control
Inversion Of ControlInversion Of Control
Inversion Of Control
 
Making react part of something greater
Making react part of something greaterMaking react part of something greater
Making react part of something greater
 
Deep Dive into React Hooks
Deep Dive into React HooksDeep Dive into React Hooks
Deep Dive into React Hooks
 

Similar a Redux pattens - JSHeroes 2018

LIMS_DOCUMENTATION
LIMS_DOCUMENTATIONLIMS_DOCUMENTATION
LIMS_DOCUMENTATION
RAHUL KUMAR
 
Memento Pattern Implementation
Memento Pattern ImplementationMemento Pattern Implementation
Memento Pattern Implementation
Steve Widom
 
Puppet Camp Portland 2015:
Puppet Camp Portland 2015: Puppet Camp Portland 2015:
Puppet Camp Portland 2015:
Puppet
 

Similar a Redux pattens - JSHeroes 2018 (20)

Advanced Redux architecture - WHAT/WHEN/WHY/HOW
Advanced Redux architecture - WHAT/WHEN/WHY/HOWAdvanced Redux architecture - WHAT/WHEN/WHY/HOW
Advanced Redux architecture - WHAT/WHEN/WHY/HOW
 
Declarative Network Configuration
Declarative Network Configuration Declarative Network Configuration
Declarative Network Configuration
 
Requirements vs design vs runtime
Requirements vs design vs runtimeRequirements vs design vs runtime
Requirements vs design vs runtime
 
Test First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in GrailsTest First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in Grails
 
Angular redux
Angular reduxAngular redux
Angular redux
 
Test First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTest First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in Grails
 
Puppet camp LA and Phoenix 2015: Keynote
Puppet camp LA and Phoenix 2015: Keynote Puppet camp LA and Phoenix 2015: Keynote
Puppet camp LA and Phoenix 2015: Keynote
 
2013 Collaborate - OAUG - Presentation
2013 Collaborate - OAUG - Presentation2013 Collaborate - OAUG - Presentation
2013 Collaborate - OAUG - Presentation
 
LIMS_DOCUMENTATION
LIMS_DOCUMENTATIONLIMS_DOCUMENTATION
LIMS_DOCUMENTATION
 
Puppeting in a Highly Regulated Industry
Puppeting in a Highly Regulated IndustryPuppeting in a Highly Regulated Industry
Puppeting in a Highly Regulated Industry
 
Command pattern vs. MVC: Lean Beans (are made of this)
Command pattern vs. MVC: Lean Beans (are made of this)Command pattern vs. MVC: Lean Beans (are made of this)
Command pattern vs. MVC: Lean Beans (are made of this)
 
Fuzzy logic
Fuzzy logicFuzzy logic
Fuzzy logic
 
Etcd- Mission Critical Key-Value Store
Etcd- Mission Critical Key-Value StoreEtcd- Mission Critical Key-Value Store
Etcd- Mission Critical Key-Value Store
 
Sql optimize
Sql optimizeSql optimize
Sql optimize
 
Memento Pattern Implementation
Memento Pattern ImplementationMemento Pattern Implementation
Memento Pattern Implementation
 
ICSE2014
ICSE2014ICSE2014
ICSE2014
 
Puppet Camp Portland 2015: Keynote
Puppet Camp Portland 2015: KeynotePuppet Camp Portland 2015: Keynote
Puppet Camp Portland 2015: Keynote
 
Puppet Camp Portland 2015:
Puppet Camp Portland 2015: Puppet Camp Portland 2015:
Puppet Camp Portland 2015:
 
Performance tuning
Performance tuningPerformance tuning
Performance tuning
 
PowerShell-and-DSC-Enables-DSCDevOps-1.pptx
PowerShell-and-DSC-Enables-DSCDevOps-1.pptxPowerShell-and-DSC-Enables-DSCDevOps-1.pptx
PowerShell-and-DSC-Enables-DSCDevOps-1.pptx
 

Más de Nir Kaufman

Más de Nir Kaufman (20)

Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
 
Angular Prestige: Less-known API and techniques
Angular Prestige: Less-known API and techniquesAngular Prestige: Less-known API and techniques
Angular Prestige: Less-known API and techniques
 
Angular CLI custom builders
Angular CLI custom buildersAngular CLI custom builders
Angular CLI custom builders
 
Electronic music 101 for developers
Electronic music 101 for developersElectronic music 101 for developers
Electronic music 101 for developers
 
Nestjs MasterClass Slides
Nestjs MasterClass SlidesNestjs MasterClass Slides
Nestjs MasterClass Slides
 
Angular EE - Special Workshop by Nir Kaufman
Angular EE - Special Workshop by Nir KaufmanAngular EE - Special Workshop by Nir Kaufman
Angular EE - Special Workshop by Nir Kaufman
 
Decorators in js
Decorators in jsDecorators in js
Decorators in js
 
Styling recipes for Angular components
Styling recipes for Angular componentsStyling recipes for Angular components
Styling recipes for Angular components
 
Introduction To Angular's reactive forms
Introduction To Angular's reactive formsIntroduction To Angular's reactive forms
Introduction To Angular's reactive forms
 
Webstorm
WebstormWebstorm
Webstorm
 
Angular Pipes Workshop
Angular Pipes WorkshopAngular Pipes Workshop
Angular Pipes Workshop
 
Data Structures in javaScript 2015
Data Structures in javaScript 2015Data Structures in javaScript 2015
Data Structures in javaScript 2015
 
Angular2 workshop
Angular2 workshopAngular2 workshop
Angular2 workshop
 
Solid angular
Solid angularSolid angular
Solid angular
 
Webpack and angularjs
Webpack and angularjsWebpack and angularjs
Webpack and angularjs
 
Angular2 - getting-ready
Angular2 - getting-ready Angular2 - getting-ready
Angular2 - getting-ready
 
Up & running with ECMAScript6
Up & running with ECMAScript6Up & running with ECMAScript6
Up & running with ECMAScript6
 
AngularJS performance & production tips
AngularJS performance & production tipsAngularJS performance & production tips
AngularJS performance & production tips
 
AngularJS - Services
AngularJS - ServicesAngularJS - Services
AngularJS - Services
 
Angular js - 10 reasons to choose angularjs
Angular js - 10 reasons to choose angularjs Angular js - 10 reasons to choose angularjs
Angular js - 10 reasons to choose angularjs
 

Último

Último (20)

2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Redux pattens - JSHeroes 2018