SlideShare a Scribd company logo
NgRx Getting Started
Gustavo Costa
Javascript, Angular, AngularJS, RxJS, Reactive
Programming, Performance, GDG Organizer
twitter.com/GustavoCostaW
Translucent - CA
linkedin.com/in/GustavoCostaW
State
State
View State
Entity Data
User Information
NgRx
= + +
Redux goals
Organizing state1
Managing state2
Communicate changes3
Why Redux?
Communicate changes1
Cache Strategy2
Pure components3
Debugging4
Performance, OnPush5
Component communication6
Maybe you do not need it
Your application is simple1
Your team is new to Angular2
Your team has a good state management pattern3
Redux Principles
Redux
Single source
of truth
Changes ONLY
by pure functions
(reducers)
State is read
ONLY and changed
ONLY by actions
Component Action
Reducer
Selector
Store (State)
View
Redux Pattern
ADD_PRODUCT
(click)=“addProduct(product)”
Get the current State
Set new State
Component notified
Updates the view
Action
Reducer
Store (State)
Component
Selector
View
Redux Pattern
Actions
Reducer
Store (State)
Let’s start - https://ngrx.io
npm install @ngrx/store --save1
StoreModule.forRoot(reducer);2
StoreModule.forFeature(‘featureName’, reducer);3
StoreModule.forRoot(reducer);
StoreModule.forFeature(reducer);
forRoot(reducer)
forFeature(‘products’, reducer)
forFeature(‘cart’, reducer)
forFeature(‘orders’, reducer)
forFeature(‘customers’, reducer)
DevTools
Let’s the demo.
Immutable vs Mutable = Array Methods
[].push(…) =1
[].concat(…) =2
[].filter(…) =3
[].map(…) =5
[].forEach() =6
[…[], newItem] =7
[].shift(…) =4 [].splice(…) =8
MUTABLE
IMMUTABLE
IMMUTABLE
MUTABLE
IMMUTABLE
MUTABLE
IMMUTABLE
MUTABLE
Smart and Dumb Comp
HTTP?
Component Action
Reducer
Selector
Store (State)
View
Redux Pattern + Effects
listening… ADD_PRODUCT
(click)=“addProduct(product)”
Get the current State


Calls GET
Component notified
Updates the view
@Effects
Service (Ajax)
ADD_PRODUCT
Set new State
Returns from 

Server


ADD_PRODUCT_SUCCESS
@Effects
Flattening Strategies
switchMap -
1 Cancels the current subscription/request and can cause race condition
* Use for get requests or cancelable requests like searches
concatMap -
2 Runs subscriptions/requests in order and is less performant
* Use for get, post and put requests when order is important
mergeMap -
3 Runs subscriptions/requests in parallel
* Use for put, post and delete methods when order is not important
exhaustMap -
4 Ignores all subsequent subscriptions/requests until it completes
* Use for login when you do not want more requests until the initial one is complete
@Effects
npm install @ngrx/effects --save1
EffectsModule.forRoot(reducer);2
EffectsModule.forFeature(‘featureName’, reducer);3
Keep learning.
Typing1
Selectors2
Schematics3
Typing
Typing
Typing
Typing
Typescript ❤
Typescript ❤
Selectors
Provide a strongly typed API1
Reusable2
Memoized (cached)3
Encapsulate complex data transformations4
Schematics
Setup1
Store2
Effect3
https://app.pluralsight.com/library/courses/
angular-ngrx-getting-started/table-of-contents
https://ngrx.io
https://angular.io
References
https://github.com/GustavoCostaW/ngrx-
getting-started
Project Sample


twitter/GustavoCostaW

linkedin/GustavoCostaW

instagram/GustavoCostaW

facebook/GustavoCostaW
❤
Ad

Recommended

Ngrx slides
Ngrx slides
Christoffer Noring
 
Ngrx: Redux in angular
Ngrx: Redux in angular
Saadnoor Salehin
 
Introduction to RxJS
Introduction to RxJS
Brainhub
 
Angular state Management-NgRx
Angular state Management-NgRx
Knoldus Inc.
 
The magic of flutter
The magic of flutter
Shady Selim
 
Angular modules in depth
Angular modules in depth
Christoffer Noring
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout
Rachel Andrew
 
Introduction to RxJS
Introduction to RxJS
Abul Hasan
 
Ngrx
Ngrx
𝙍𝙖𝙩𝙝𝙤𝙧𝙚 𝙎𝙪𝙬𝙞𝙜𝙮𝙖
 
React + Redux Introduction
React + Redux Introduction
Nikolaus Graf
 
Introduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace IT
namespaceit
 
State Management in Angular/React
State Management in Angular/React
DEV Cafe
 
Introduction to Redux
Introduction to Redux
Ignacio Martín
 
React and redux
React and redux
Mystic Coders, LLC
 
Introduction to react_js
Introduction to react_js
MicroPyramid .
 
Introduction to React
Introduction to React
Rob Quick
 
Introduction to ReactJS
Introduction to ReactJS
Knoldus Inc.
 
An introduction to React.js
An introduction to React.js
Emanuele DelBono
 
React workshop presentation
React workshop presentation
Bojan Golubović
 
A Brief Introduction to React.js
A Brief Introduction to React.js
Doug Neiner
 
React hooks
React hooks
Assaf Gannon
 
React js
React js
Rajesh Kolla
 
Its time to React.js
Its time to React.js
Ritesh Mehrotra
 
Redux workshop
Redux workshop
Imran Sayed
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)
Tomáš Drenčák
 
React hooks
React hooks
Sadhna Rana
 
React js
React js
Jai Santhosh
 
Angular
Angular
sridhiya
 
STATE MANAGEMENT IN REACT [Autosaved].pptx
STATE MANAGEMENT IN REACT [Autosaved].pptx
siddheshjadhav919123
 
Redux data flow with angular
Redux data flow with angular
Gil Fink
 

More Related Content

What's hot (20)

Ngrx
Ngrx
𝙍𝙖𝙩𝙝𝙤𝙧𝙚 𝙎𝙪𝙬𝙞𝙜𝙮𝙖
 
React + Redux Introduction
React + Redux Introduction
Nikolaus Graf
 
Introduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace IT
namespaceit
 
State Management in Angular/React
State Management in Angular/React
DEV Cafe
 
Introduction to Redux
Introduction to Redux
Ignacio Martín
 
React and redux
React and redux
Mystic Coders, LLC
 
Introduction to react_js
Introduction to react_js
MicroPyramid .
 
Introduction to React
Introduction to React
Rob Quick
 
Introduction to ReactJS
Introduction to ReactJS
Knoldus Inc.
 
An introduction to React.js
An introduction to React.js
Emanuele DelBono
 
React workshop presentation
React workshop presentation
Bojan Golubović
 
A Brief Introduction to React.js
A Brief Introduction to React.js
Doug Neiner
 
React hooks
React hooks
Assaf Gannon
 
React js
React js
Rajesh Kolla
 
Its time to React.js
Its time to React.js
Ritesh Mehrotra
 
Redux workshop
Redux workshop
Imran Sayed
 
State management in react applications (Statecharts)
State management in react applications (Statecharts)
Tomáš Drenčák
 
React hooks
React hooks
Sadhna Rana
 
React js
React js
Jai Santhosh
 
Angular
Angular
sridhiya
 

Similar to Getting Started with NgRx (Redux) Angular (20)

STATE MANAGEMENT IN REACT [Autosaved].pptx
STATE MANAGEMENT IN REACT [Autosaved].pptx
siddheshjadhav919123
 
Redux data flow with angular
Redux data flow with angular
Gil Fink
 
Redux State Management System A Comprehensive Review
Redux State Management System A Comprehensive Review
ijtsrd
 
Redux data flow with angular 2
Redux data flow with angular 2
Gil Fink
 
Introduction to react and redux
Introduction to react and redux
Cuong Ho
 
Getting started with Redux js
Getting started with Redux js
Citrix
 
Redux data flow with angular
Redux data flow with angular
Gil Fink
 
Advanced Redux architecture - WHAT/WHEN/WHY/HOW
Advanced Redux architecture - WHAT/WHEN/WHY/HOW
Mateusz Bosek
 
React state managmenet with Redux
React state managmenet with Redux
Vedran Blaženka
 
Redux
Redux
Maulik Shah
 
Redux Like Us
Redux Like Us
Heber Silva
 
Materi Modern React Redux Power Point.pdf
Materi Modern React Redux Power Point.pdf
exiabreak
 
The Redux Introduction in react and applications .
The Redux Introduction in react and applications .
Lalith86
 
Redux
Redux
Anurag Chitti
 
React Redux Interview Questions PDF By ScholarHat
React Redux Interview Questions PDF By ScholarHat
Scholarhat
 
React Redux Interview Questions PDF By ScholarHat
React Redux Interview Questions PDF By ScholarHat
Scholarhat
 
Integrating React.js with PHP projects
Integrating React.js with PHP projects
Ignacio Martín
 
React
React
Amitai Barnea
 
downloads_introduction to redux.pptx
downloads_introduction to redux.pptx
NavneetKumar111924
 
U3-02-React Redux and MUI.pptxaSDFGNXDASDFG
U3-02-React Redux and MUI.pptxaSDFGNXDASDFG
vinodkumarthatipamul
 
STATE MANAGEMENT IN REACT [Autosaved].pptx
STATE MANAGEMENT IN REACT [Autosaved].pptx
siddheshjadhav919123
 
Redux data flow with angular
Redux data flow with angular
Gil Fink
 
Redux State Management System A Comprehensive Review
Redux State Management System A Comprehensive Review
ijtsrd
 
Redux data flow with angular 2
Redux data flow with angular 2
Gil Fink
 
Introduction to react and redux
Introduction to react and redux
Cuong Ho
 
Getting started with Redux js
Getting started with Redux js
Citrix
 
Redux data flow with angular
Redux data flow with angular
Gil Fink
 
Advanced Redux architecture - WHAT/WHEN/WHY/HOW
Advanced Redux architecture - WHAT/WHEN/WHY/HOW
Mateusz Bosek
 
React state managmenet with Redux
React state managmenet with Redux
Vedran Blaženka
 
Materi Modern React Redux Power Point.pdf
Materi Modern React Redux Power Point.pdf
exiabreak
 
The Redux Introduction in react and applications .
The Redux Introduction in react and applications .
Lalith86
 
React Redux Interview Questions PDF By ScholarHat
React Redux Interview Questions PDF By ScholarHat
Scholarhat
 
React Redux Interview Questions PDF By ScholarHat
React Redux Interview Questions PDF By ScholarHat
Scholarhat
 
Integrating React.js with PHP projects
Integrating React.js with PHP projects
Ignacio Martín
 
downloads_introduction to redux.pptx
downloads_introduction to redux.pptx
NavneetKumar111924
 
U3-02-React Redux and MUI.pptxaSDFGNXDASDFG
U3-02-React Redux and MUI.pptxaSDFGNXDASDFG
vinodkumarthatipamul
 
Ad

More from Gustavo Costa (10)

Trabalho remoto + Carreira Internacional em T.I
Trabalho remoto + Carreira Internacional em T.I
Gustavo Costa
 
Angular Extreme Performance - V2
Angular Extreme Performance - V2
Gustavo Costa
 
Google Calendar API - Getting Started
Google Calendar API - Getting Started
Gustavo Costa
 
Angular Extreme Performance
Angular Extreme Performance
Gustavo Costa
 
Angular - Um novo change detection
Angular - Um novo change detection
Gustavo Costa
 
Ionic 2 como ferramenta para desenvolvimento móvel
Ionic 2 como ferramenta para desenvolvimento móvel
Gustavo Costa
 
Angular.JS - Estado Atual
Angular.JS - Estado Atual
Gustavo Costa
 
Desenvolvendo APPs Com Angular.JS + Cordova
Desenvolvendo APPs Com Angular.JS + Cordova
Gustavo Costa
 
Abra sua cabeça, apps híbridos - PhoneGap/Cordova
Abra sua cabeça, apps híbridos - PhoneGap/Cordova
Gustavo Costa
 
Mobile - Abra sua cabeça.
Mobile - Abra sua cabeça.
Gustavo Costa
 
Trabalho remoto + Carreira Internacional em T.I
Trabalho remoto + Carreira Internacional em T.I
Gustavo Costa
 
Angular Extreme Performance - V2
Angular Extreme Performance - V2
Gustavo Costa
 
Google Calendar API - Getting Started
Google Calendar API - Getting Started
Gustavo Costa
 
Angular Extreme Performance
Angular Extreme Performance
Gustavo Costa
 
Angular - Um novo change detection
Angular - Um novo change detection
Gustavo Costa
 
Ionic 2 como ferramenta para desenvolvimento móvel
Ionic 2 como ferramenta para desenvolvimento móvel
Gustavo Costa
 
Angular.JS - Estado Atual
Angular.JS - Estado Atual
Gustavo Costa
 
Desenvolvendo APPs Com Angular.JS + Cordova
Desenvolvendo APPs Com Angular.JS + Cordova
Gustavo Costa
 
Abra sua cabeça, apps híbridos - PhoneGap/Cordova
Abra sua cabeça, apps híbridos - PhoneGap/Cordova
Gustavo Costa
 
Mobile - Abra sua cabeça.
Mobile - Abra sua cabeça.
Gustavo Costa
 
Ad

Recently uploaded (20)

Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 
Daily Lesson Log MATATAG ICT TEchnology 8
Daily Lesson Log MATATAG ICT TEchnology 8
LOIDAALMAZAN3
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
Connecting Data and Intelligence: The Role of FME in Machine Learning
Connecting Data and Intelligence: The Role of FME in Machine Learning
Safe Software
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Quantum AI Discoveries: Fractal Patterns Consciousness and Cyclical Universes
Saikat Basu
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
AI Agents and FME: A How-to Guide on Generating Synthetic Metadata
Safe Software
 
Quantum AI: Where Impossible Becomes Probable
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
 

Getting Started with NgRx (Redux) Angular