@simona_cotin
State management
with ngRx
@simona_cotin
@simona_cotin
Simona Cotin
Cloud Dev Advocate @ Microsoft
@simona_cotin
@simona_cotin
ngRx
@simona_cotin
@simona_cotin
@simona_cotin
@simona_cotin
✓ Recognise
✓ Make decisions faster
✓ Comfort
@simona_cotin
State
management
@simona_cotin
A day in the life of a component
✓Initialize state
✓Request data from the server
✓Update state to reflect server
data
✓React to events that change
the state
✓Update state to reflect user
interaction
✓Receive state updates from
other components 😱
✓…
@simona_cotin
And this is fine!
@simona_cotin
When you work in
a small team
@simona_cotin
And have a small
number of components
that are not
communicating heavily
@simona_cotin
But..what happens
when you’re
building a large
application?
@simona_cotin
@simona_cotin
@simona_cotin
Component
✓Render itself
✓Initialize state
✓Request data from the server
✓Update state to reflect server
data
✓React to events that change
the state
✓Update state to reflect user
interaction
✓Receive state updates from
other components 😱
✓…
@simona_cotin
Smart Component
Component
Presentation
Component
Input
Output
@simona_cotin
How things work?
Component
Presentation
Component
Input
Output
@simona_cotin
How things work?
Component
How things look?
Input
Output
@simona_cotin
😼😼😼
@simona_cotin
State management with ngRX
State management with ngRX
@simona_cotin
We call that the
store
How to get state
from the store?
Component
How to get state from the store?
store.select('counter')
How to change state?
@simona_cotin
Component
Reducer
Action
State
How to change state?
@simona_cotinPhoto by Sam Burriss on Unsplash
@simona_cotin– https://redux.js.org
“Redux is a
predictable state
container for
JavaScript apps.”
@simona_cotin
Redux
Single source of truth
Read-only state
Pure functions
@simona_cotin
Single State Tree{
visibilityFilter: 'SHOW_ALL',
todos: [
{
text: 'Consider using Redux',
completed: true,
},
{
text: 'Keep all state in a single tree',
completed: false
}
]
}
@simona_cotin
Actions
const action = {
type: 'ADD_TODO',
payload: 'learn ngRx'
}
@simona_cotin
const reducer = (state = [], action) => {
switch (action.type) {
case 'ADD_TODO':
return [...state, action.payload];
default:
return state;
}
};
Reducer
s
@simona_cotin
WIIFM (What’s In It For
Me?)
✓ Patterns 🤩❤️😎
✓ Centralised state
✓ Testability
✓ Tooling and ecosystem
@simona_cotin
–you
“What about
angular?”
@simona_cotin
ngRx
@simona_cotin
A collection of libraries
that help with state
management in
angular
@simona_cotin
@simona_cotin
WIIFM? 🤩🤩
✓ Patterns 🤩❤️😎
✓ Single source of truth/centralised state
✓ Testability
✓ Tooling
@simona_cotin
@simona_cotin
Demo
@simona_cotin
Common use cases
✓ Trading apps
✓ Network data monitoring
✓ Wizard like apps
@simona_cotin
This is also OK 🤩
@simona_cotin
–Victor Savkin
“Careful thinking
cannot be
replaced by a
library.”
@simona_cotin
Tools to consider
@simona_cotin
Happy thoughts
• Simpler state management
• Testability
• Tooling
• 😍 Time travel debugging
@simona_cotin
Thank you
@MarkPieszak@elmd_

More Related Content

PPTX
Frontend State management
PDF
Angular state Management-NgRx
PPTX
Mukesh sharma
PDF
Introduction to Redux (for Angular and React devs)
PDF
React state management with Redux and MobX
PPTX
unit 2 Mastering-State-Management-in-React.pptx
PDF
Making react part of something greater
PPTX
Managing State & HTTP Requests In Ionic.
Frontend State management
Angular state Management-NgRx
Mukesh sharma
Introduction to Redux (for Angular and React devs)
React state management with Redux and MobX
unit 2 Mastering-State-Management-in-React.pptx
Making react part of something greater
Managing State & HTTP Requests In Ionic.

Similar to State management with ngRX (20)

PPTX
Boost js state management
PDF
Getting Started with NgRx (Redux) Angular
PDF
react redux.pdf
PDF
ReactRedux.pdf
PDF
React.js and Redux overview
PDF
Handling State in React: Context API vs. Redux
PPTX
React learning in the hard way
PPTX
Cracking web development
PDF
Redux essentials
PPTX
Best Website Designing Company in Amritsar for Mobile-Responsive Sites
PPTX
STATE MANAGEMENT IN REACT [Autosaved].pptx
PDF
Redux State Management System A Comprehensive Review
PPTX
𝐀𝐧 𝐈𝐧𝐭𝐞𝐫𝐚𝐜𝐭𝐢𝐯𝐞 𝐒𝐞𝐬𝐬𝐢𝐨𝐧 𝐨𝐧 𝐀𝐧𝐠𝐮𝐥𝐚𝐫 𝐍𝐠𝐑𝐱 𝐛𝐲 𝐀𝐧𝐠𝐮𝐥𝐚𝐫 𝐃𝐞𝐯𝐞𝐥𝐨𝐩𝐦𝐞𝐧𝐭 𝐓𝐞𝐚𝐦
PDF
A React Journey
PDF
a-detailed-guide-everything-you-need-to-know-about-reactjs.pdf
PPTX
State management in react applications (Statecharts)
PDF
JS Experience 2017 - Reactive Interfaces com React & RxJS
PPTX
React JS and MEmmmRN Stack Overview.pptx
ODP
Appstate
PPTX
React state management paradigms, Роман Якобчук
Boost js state management
Getting Started with NgRx (Redux) Angular
react redux.pdf
ReactRedux.pdf
React.js and Redux overview
Handling State in React: Context API vs. Redux
React learning in the hard way
Cracking web development
Redux essentials
Best Website Designing Company in Amritsar for Mobile-Responsive Sites
STATE MANAGEMENT IN REACT [Autosaved].pptx
Redux State Management System A Comprehensive Review
𝐀𝐧 𝐈𝐧𝐭𝐞𝐫𝐚𝐜𝐭𝐢𝐯𝐞 𝐒𝐞𝐬𝐬𝐢𝐨𝐧 𝐨𝐧 𝐀𝐧𝐠𝐮𝐥𝐚𝐫 𝐍𝐠𝐑𝐱 𝐛𝐲 𝐀𝐧𝐠𝐮𝐥𝐚𝐫 𝐃𝐞𝐯𝐞𝐥𝐨𝐩𝐦𝐞𝐧𝐭 𝐓𝐞𝐚𝐦
A React Journey
a-detailed-guide-everything-you-need-to-know-about-reactjs.pdf
State management in react applications (Statecharts)
JS Experience 2017 - Reactive Interfaces com React & RxJS
React JS and MEmmmRN Stack Overview.pptx
Appstate
React state management paradigms, Роман Якобчук
Ad

More from Simona Cotin (19)

PDF
Tips and tricks on how to stand out with your bio and talk abstract
PDF
Serverless at the end of the Universe
PPTX
Tech Roadmap
PPTX
Build scalable APIs using GraphQL and Serverless
PPTX
Pwa, are we there yet?!
PPTX
Intro GraphQL
PPTX
Build Nodejs APIs using Serverless
PPTX
PWAs, are we there yet?!
PDF
Doppelganger - ng-conf
PDF
Build a look alike engine with machine learning and Angular
PDF
Hop on the serverless adventure - International Javascript London
PPTX
Build progressive web apps with Angular
PDF
Deploy Angular to the Cloud (ngBucharest)
PDF
Build and Deploy Angular to the Cloud
PPTX
Serverless adventure tooling
PDF
Code and Deploy Angular to the Cloud
PDF
Deploy Angular to the Cloud
PDF
From Angular to React and back again
DOCX
Music Finder
Tips and tricks on how to stand out with your bio and talk abstract
Serverless at the end of the Universe
Tech Roadmap
Build scalable APIs using GraphQL and Serverless
Pwa, are we there yet?!
Intro GraphQL
Build Nodejs APIs using Serverless
PWAs, are we there yet?!
Doppelganger - ng-conf
Build a look alike engine with machine learning and Angular
Hop on the serverless adventure - International Javascript London
Build progressive web apps with Angular
Deploy Angular to the Cloud (ngBucharest)
Build and Deploy Angular to the Cloud
Serverless adventure tooling
Code and Deploy Angular to the Cloud
Deploy Angular to the Cloud
From Angular to React and back again
Music Finder
Ad

Recently uploaded (20)

PPTX
Full-Stack Developer Courses That Actually Land You Jobs
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
DOC
UTEP毕业证学历认证,宾夕法尼亚克拉里恩大学毕业证未毕业
PDF
Practical Indispensable Project Management Tips for Delivering Successful Exp...
PPTX
Tech Workshop Escape Room Tech Workshop
PPTX
Airline CRS | Airline CRS Systems | CRS System
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PDF
MCP Security Tutorial - Beginner to Advanced
PPTX
Computer Software - Technology and Livelihood Education
PPTX
GSA Content Generator Crack (2025 Latest)
PPTX
Download Adobe Photoshop Crack 2025 Free
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PPTX
"Secure File Sharing Solutions on AWS".pptx
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
DOCX
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx
Full-Stack Developer Courses That Actually Land You Jobs
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
Wondershare Recoverit Full Crack New Version (Latest 2025)
Introduction to Ragic - #1 No Code Tool For Digitalizing Your Business Proces...
UTEP毕业证学历认证,宾夕法尼亚克拉里恩大学毕业证未毕业
Practical Indispensable Project Management Tips for Delivering Successful Exp...
Tech Workshop Escape Room Tech Workshop
Airline CRS | Airline CRS Systems | CRS System
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
MCP Security Tutorial - Beginner to Advanced
Computer Software - Technology and Livelihood Education
GSA Content Generator Crack (2025 Latest)
Download Adobe Photoshop Crack 2025 Free
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
"Secure File Sharing Solutions on AWS".pptx
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
How Tridens DevSecOps Ensures Compliance, Security, and Agility
Modern SharePoint Intranet Templates That Boost Employee Engagement in 2025.docx

State management with ngRX

Editor's Notes

  • #4: Who am I?
  • #7: Developers like to put everything in a box, neatly arranged and with a clear purpose
  • #8: Moreover, we want everything to be a pattern
  • #10: Patterns allow us to recognise things we’ve seen before, enable us to make decisions faster and give us a sense of comfort, I got this!
  • #11: And with state management we first handled everything in our component
  • #17: Getting crowded
  • #18: Maintaining this type of system and not being very deliberate about your state management strategy will kinda come back and bite you in the arse.
  • #20: Our smart component is concerned of how things work; don’t really have Dom markup, maybe just some wrapping divs. It’s responsible for providing data and behaviour to our presentational component Our presentational components are concerned with how things look
  • #21: Our smart component is concerned of how things work; don’t really have Dom markup, maybe just some wrapping divs. It’s responsible for providing data and behaviour to our presentational component Our presentational components are concerned with how things look
  • #22: Our smart component is concerned of how things work; don’t really have Dom markup, maybe just some wrapping divs. It’s responsible for providing data and behaviour to our presentational component Our presentational components are concerned with how things look
  • #23: And this is great, it helps us isolate state only to certain components And we get patterns. Yay But the state is still spread across multiple components And we still haven’t solved the problem of component communication
  • #24: Diagram - highlight where the state is, point at different parts that have state, sidebar Let’s look at this component, where do we find state?
  • #28: Smart vs dumb components Shared data between services - loose control, hard to debug All in one place
  • #34: Neatly formalised
  • #37: And our single source of truth is this One big plain javascript object; everything is kept as one big object and is composed by reducers
  • #38: i. Two properties: 1. Type – string, describes the event - required 2. Payload: optional data; imagine for our initial page we want to load todos, we don’t need a payload, we just go ahead and request some data from the backend
  • #39: i. Pure functions ii. Given dispatched action: 1. Responds to action type, 2. Has access to action.payload 3. Composes new state 4. Returns new state
  • #40: Centralised state, which is easier to reason about Better testability, remember our reducers which update our state are pure functions and pure functions are so easy to test
  • #45: Redux/NGRX is awesome, it gives us predictable immutable state containers that enable efficient change detection and de-coupling of components. 
  • #48: Applications that deal with lots of data flows changing all the time, like trading apps or network data monitoring apps Also suitable for apps that are almost like a state machine - wizard like
  • #49: https://twitter.com/tjholowaychuk/status/957853652483416064
  • #50: You need to be intentional about state management, make sure to have a strategy and an easy way for developers to work together
  • #53: Start with a question? We have reducers, what do we miss? You need to get data from the server? Reducers, pure functions To perform side effects - Reducers represent sections, or slices of state within your application and should be structured and composed accordingly.