SlideShare a Scribd company logo
Dumb and smart
components & redux
Brecht Billiet
About me
Brecht Billiet
Frontend Architect - Coach - Trainer
http://brecht.io @brechtbilliet
Who still uses ng-
controller and ng-
include?
Doesn’t that bother you?
● What HTML belongs to what JS?
● Where do the templates live?
● Absolute template-paths are not maintainable
● What logic belongs in a controller or directive?
● This template should contain... oh wait, there is an ng-include there.
● How do you pass data to your controllers?
Think in components...
● 1 piece HTML + 1 piece LOGIC = COMPONENT
● You know it as: element directives
● Custom DOM tags
● A component has a single responsability
● We could use webcomponents + shadow DOM
● Sandboxed work
● Note: angular 1.5 has new component syntax
What should you
refactor to
components?
Dumb and smart components + redux (1)
Everything is a component
● Your application is a tree of components
● Your pages are components
● Even your application is a component
application
Html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
application
Html + js
+ css
fooPage
html + js
+ css
html + js
+ css
barPage
html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
html + js
+ css
Routingconfig:
template: ‘<foo-page/>’
Routingconfig:
template: ‘<bar-page/>’
Easier to debug
Other advantages
● No scope soup
● Nice hierarchy view
● Single responsability
● No more absolute paths
● Easier to reason about
● Easier to refactor
● Easier to upgrade to ng2
What about attribute-directives?
● Let’s call them behaviors from now
● They add some logic to existing or custom components
● Separate them from your components folder
DEMO
http://winecellar.surge.sh
http://winecellar.surge.sh: components
Any rules of thumb?
Dumb and smart components + redux (1)
Keep them small...
Keep them dumb where possible...
Dumb component Smart component (container)
Doesn’t know about the
application
Knows about the application
Doesn’t do data fetching Does data fetching
Main purpose is visualization Interacts the application
Reusable Not reusable
Only communicates with its direct
parent
Passes state and data to its
children
Doesn’t do state management Does state management
http://winecellar.surge.sh: Smart
components
http://winecellar.surge.sh: Dumb
components
State management
● State is very hard to manage in SPA’s
● State can be
○ data: results from REST calls
○ “sidebar is collapsed” or “spinner is active”
○ Which tab is currently active
State management
● 3 types of state
○ Data state
○ Application state
○ Inner state (e.g value of textbox) We don’t have to persist nor manage that
Why is it so hard to manage?
● 1-way databinding and 2-way databinding
● javascript references that are being broken and sometimes kept
● We can mutate the data in a million different ways
● No structure
● Data flows in different directions
application
state &
logic
state &
logic
state &
logic
state &
logic
state &
logic
state &
logic
state &
logic
state &
logic
state &
logic
state &
logic
Without flux
1
2
5 6
3
7 8
4
9
10 11
Without flux
1
2
5 6
3
7 8
4
9
10 11
I changed
Without flux
1
2
5 6
3
7 8
4
9
10 11
I changed
So did I
Without flux
1
2
5 6
3
7 8
4
9
10 11
I changed
So did I
My changes
should
reflect 6 and
4
Without flux
1
2
5 6
3
7 8
4
9
10 11
I changed
So did I
My changes
should
reflect 6 and
4
I have to
subscribe
before 8
sends a
message
Without flux
1
2
5 6
3
7 8
4
9
10 11
I changed
So did I
My changes
should
reflect 6 and
4
I have to
subscribe
before 8
sends a
message
I’m sending
an event
upwards
Without flux
1
2
5 6
3
7 8
4
9
10 11
I changed
So did I
My changes
should
reflect 6 and
4
I have to
subscribe
before 8
sends a
message
I’m sending
an event
upwards
I’m sending
events
downwards
Without flux
1
2
5 6
3
7 8
4
9
10 11
I changed
So did I
My changes
should
reflect 6 and
4
I have to
subscribe
before 8
sends a
message
I’m sending
an event
upwards
Without flux
I’m sending
events
downwards
1
2
5 6
3
7 8
4
9
10 11
I changed
So did I
My changes
should
reflect 6 and
4
I have to
subscribe
before 8
sends a
message
I’m sending
an event
upwards
I get my data
from model x
and I can
update it
here
I get my data
from model z
Without flux
I’m sending
events
downwards
I get my data
from model y
1
2
5 6
3
7 8
4
9
10 11
I changed
So did I
My changes
should
reflect 6 and
4
I have to
subscribe
before 8
sends a
message
I’m sending
an event
upwards
I get my data
from model x
and I can
update it
here
I get my data
from model z
Without flux
My data is
passed by
twoway
binding
I’m sending
events
downwards
I get my data
from model y
My data is
passed by
oneway
binding
My data is
passed by
twoway
binding
Where do those states/events come from?
Who updated my state??
Who updated/notified which component?
Dumb and smart components + redux (1)
Flux helps with that
● Brings structure in data flow
● Not a framework but an architecture by facebook
● Unidirectional dataflow, oneway databinding
● Data flows from the top down
● Easier to reason about state
● Action
○ Has an action type and a payload
● Dispatcher
○ Dispatches the actions to the store
● Store
○ Contains state
● View
Components
● The unidirectional dataflow makes it easy to reason about
I use Redux!
Redux is based on
flux, but it’s easier
Redux
● Written by Dan Abramov (Facebook)
● Easier to use and less bloat
● Only has one store!!
● Completely Immutable data structure
● Uses reducers (pure functions)
● Flux approves
1
2
5 6
3
7 8
4
9
10 11
STORE
1
2
5 6
3
7 8
4
9
10 11
Me too
Me too
Me too
Me too
STORE
I only send
actions
upwards to the
store
I’m the single-
source-of-truth
in your
application!! ;-)
1
2
5 6
3
7 8
4
9
10 11
Me too
Me too
I’m dumb I’m dumb
I’m dumb I’m dumb
I’m dumb
I’m dumb
STORE
Me too
I only send
actions
upwards to the
store Me too
I’m the single-
source-of-truth
in your
application!! ;-)
Dumb components only
notify their direct parents!
No state management
needed here :-)
What’s different?
● We have one single source of truth: the store
● We don’t update state ourselves anymore, the store handles all the state of
our application
● State is immutable
● Actions are always sent upwards
What’s different?
● Dumb components don’t do state management
● State is being updated by pure functions (reducers)
● When the store is updated it notifies all the smart components
Application state
Actions
● Actions have a type and a payload
● Keep the types together, gives clear overview
Actions
Reducers
● Pure functions
● reducer(state: MyState, action: Action): MyState
● they update the state
● Completely immutable
Reducers
Example in container
Middleware
● Easy logging, debugging
● Reproducible action state (pushable to server)
● Timetraveling with redux-devtools (requires react to be bundled in the
angular project)
Check it out
● egghead.io course (Free)
○ https://egghead.io/series/getting-started-with-redux
Special thanks to
● Kwinten Pisman (@kwintenp)
● Jurgen Van de Moere (@jvandemo)
Questions?
One more thing
Angular2, rxjs, redux,
@ngrx/store, Typescript,
webpack
http://workshop.brecht.io @brechtbilliet
Workshop
June 2016
Thank you!

More Related Content

What's hot (19)

PDF
Let Codenarc check if you write good Groovy code
Alberto De Ávila Hernández
 
PPTX
Html 5 tutorial - By Bally Chohan
ballychohanuk
 
PDF
TechSEO Boost 2021 - Rendering Strategies: Measuring the Devil’s Details in C...
Catalyst
 
PDF
Write Once, Run Everywhere
Mike North
 
PDF
Software Testing for SEO
Michael King
 
PDF
Nitro for your Grails App: How to improve performance!! Greach' 18
Alberto Barón Cuevas
 
PDF
Accessibility Report for training website
Alex Criswell, M.A. & M.S. Ed
 
PPT
HTML5 with examples
gopivthmk
 
PDF
Headless SEO: Optimising Next Gen Sites | brightonSEO 2021
Alex Wright
 
PPTX
Behaviour Driven Development
Andy Kelk
 
PDF
What I learned teaching programming to 150 beginners
Etiene Dalcol
 
PDF
SEO Checklist for Google Mobile First Index
Erudite
 
PPTX
2 Seconds is the New Slow - Chris Simmance - under2
Chris Simmance
 
PDF
Rich HTML5 Web Apps: Typesafe Edition
csadilek
 
PPTX
Technical SEO "Overoptimization"
Hamlet Batista
 
PPTX
The New Renaissance of JavaScript
Hamlet Batista
 
PDF
React native - What, Why, How?
Teerasej Jiraphatchandej
 
PPTX
TechSEO Boost 2018: The Statelessness of Technical SEO
Catalyst
 
PDF
The Great Migration: Moving Your SharePoint | Fpwebinar
Fpweb
 
Let Codenarc check if you write good Groovy code
Alberto De Ávila Hernández
 
Html 5 tutorial - By Bally Chohan
ballychohanuk
 
TechSEO Boost 2021 - Rendering Strategies: Measuring the Devil’s Details in C...
Catalyst
 
Write Once, Run Everywhere
Mike North
 
Software Testing for SEO
Michael King
 
Nitro for your Grails App: How to improve performance!! Greach' 18
Alberto Barón Cuevas
 
Accessibility Report for training website
Alex Criswell, M.A. & M.S. Ed
 
HTML5 with examples
gopivthmk
 
Headless SEO: Optimising Next Gen Sites | brightonSEO 2021
Alex Wright
 
Behaviour Driven Development
Andy Kelk
 
What I learned teaching programming to 150 beginners
Etiene Dalcol
 
SEO Checklist for Google Mobile First Index
Erudite
 
2 Seconds is the New Slow - Chris Simmance - under2
Chris Simmance
 
Rich HTML5 Web Apps: Typesafe Edition
csadilek
 
Technical SEO "Overoptimization"
Hamlet Batista
 
The New Renaissance of JavaScript
Hamlet Batista
 
React native - What, Why, How?
Teerasej Jiraphatchandej
 
TechSEO Boost 2018: The Statelessness of Technical SEO
Catalyst
 
The Great Migration: Moving Your SharePoint | Fpwebinar
Fpweb
 

Viewers also liked (17)

PPTX
Redux in Angular2 for jsbe
Brecht Billiet
 
PPTX
React + Redux Introduction
Nikolaus Graf
 
PPTX
Into the Land of lambda, One Programmer's Journey Into Functional Programming
Mike Pence
 
PPTX
React. Flux. Redux. by Andrey Kolodnitskiy
Valeriia Maliarenko
 
PDF
Understanding Redux — Ilya Gelman
500Tech
 
PDF
Application architecture doesn't have to suck
jtregunna
 
PDF
The evolution of redux action creators
George Bukhanov
 
PDF
Side Effects: Uma Saga até o React
Paulo Pires
 
PPT
'Did He Really Say That?" effective component communication
Gus Sabatino
 
PPTX
React. Flux. Redux
Andrey Kolodnitsky
 
PPTX
The redux saga begins
Daniel Franz
 
PDF
Angular 2 Component Communication - Talk by Rob McDiarmid
Amrita Chopra
 
PDF
Simple made easy
Lee Wei Yeong
 
PDF
RxJS + Redux + React = Amazing
Jay Phelps
 
PDF
Are we there yet?
UCD Library
 
PDF
Asyc flow control with javascript generators - redux-saga
Pedro Solá
 
PDF
UX Jam x UX Sketch 2017 HD
Yukio Andoh
 
Redux in Angular2 for jsbe
Brecht Billiet
 
React + Redux Introduction
Nikolaus Graf
 
Into the Land of lambda, One Programmer's Journey Into Functional Programming
Mike Pence
 
React. Flux. Redux. by Andrey Kolodnitskiy
Valeriia Maliarenko
 
Understanding Redux — Ilya Gelman
500Tech
 
Application architecture doesn't have to suck
jtregunna
 
The evolution of redux action creators
George Bukhanov
 
Side Effects: Uma Saga até o React
Paulo Pires
 
'Did He Really Say That?" effective component communication
Gus Sabatino
 
React. Flux. Redux
Andrey Kolodnitsky
 
The redux saga begins
Daniel Franz
 
Angular 2 Component Communication - Talk by Rob McDiarmid
Amrita Chopra
 
Simple made easy
Lee Wei Yeong
 
RxJS + Redux + React = Amazing
Jay Phelps
 
Are we there yet?
UCD Library
 
Asyc flow control with javascript generators - redux-saga
Pedro Solá
 
UX Jam x UX Sketch 2017 HD
Yukio Andoh
 
Ad

Similar to Dumb and smart components + redux (1) (20)

PDF
Introduction to Redux (for Angular and React devs)
Fabio Biondi
 
PDF
Redux in Angular 2+
Hùng Nguyễn Huy
 
PDF
Angular redux
Nir Kaufman
 
PDF
The Road To Redux
Jeffrey Sanchez
 
PDF
Front end architecture patterns
Oleksandr Tryshchenko
 
PDF
Evan Schultz - Angular Summit - 2016
Evan Schultz
 
PPTX
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio
 
PDF
Redux with angular 2 - workshop 2016
Nir Kaufman
 
PDF
ngSummit 2017: Angular meets Redux
Michał Michalczuk
 
PDF
Smart and Dumb Components
Shai Reznik
 
PDF
redux and angular - up and running
Nir Kaufman
 
PDF
Predictable reactive state management - ngrx
Ilia Idakiev
 
PPTX
Reducers+flux=redux
Shmulik Chicvashvili
 
PDF
Building React Applications with Redux
FITC
 
PPTX
Fluxish Angular
Filip Janevski
 
PDF
Fabio Biondi - Front-end data architectures in Angular, Redux & NGRX - Codemo...
Codemotion
 
PPTX
React & redux
Cédric Hartland
 
PDF
The State of Front-end At CrowdTwist
Mark Fayngersh
 
PDF
Redux js
Nils Petersohn
 
PPTX
React.js at Cortex
Geoff Harcourt
 
Introduction to Redux (for Angular and React devs)
Fabio Biondi
 
Redux in Angular 2+
Hùng Nguyễn Huy
 
Angular redux
Nir Kaufman
 
The Road To Redux
Jeffrey Sanchez
 
Front end architecture patterns
Oleksandr Tryshchenko
 
Evan Schultz - Angular Summit - 2016
Evan Schultz
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
Binary Studio
 
Redux with angular 2 - workshop 2016
Nir Kaufman
 
ngSummit 2017: Angular meets Redux
Michał Michalczuk
 
Smart and Dumb Components
Shai Reznik
 
redux and angular - up and running
Nir Kaufman
 
Predictable reactive state management - ngrx
Ilia Idakiev
 
Reducers+flux=redux
Shmulik Chicvashvili
 
Building React Applications with Redux
FITC
 
Fluxish Angular
Filip Janevski
 
Fabio Biondi - Front-end data architectures in Angular, Redux & NGRX - Codemo...
Codemotion
 
React & redux
Cédric Hartland
 
The State of Front-end At CrowdTwist
Mark Fayngersh
 
Redux js
Nils Petersohn
 
React.js at Cortex
Geoff Harcourt
 
Ad

Recently uploaded (20)

PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 

Dumb and smart components + redux (1)

  • 1. Dumb and smart components & redux Brecht Billiet
  • 2. About me Brecht Billiet Frontend Architect - Coach - Trainer http://brecht.io @brechtbilliet
  • 3. Who still uses ng- controller and ng- include?
  • 4. Doesn’t that bother you? ● What HTML belongs to what JS? ● Where do the templates live? ● Absolute template-paths are not maintainable ● What logic belongs in a controller or directive? ● This template should contain... oh wait, there is an ng-include there. ● How do you pass data to your controllers?
  • 5. Think in components... ● 1 piece HTML + 1 piece LOGIC = COMPONENT ● You know it as: element directives ● Custom DOM tags ● A component has a single responsability ● We could use webcomponents + shadow DOM ● Sandboxed work ● Note: angular 1.5 has new component syntax
  • 6. What should you refactor to components?
  • 8. Everything is a component ● Your application is a tree of components ● Your pages are components ● Even your application is a component
  • 9. application Html + js + css html + js + css html + js + css html + js + css html + js + css html + js + css html + js + css html + js + css html + js + css html + js + css html + js + css
  • 10. application Html + js + css fooPage html + js + css html + js + css barPage html + js + css html + js + css html + js + css html + js + css html + js + css html + js + css Routingconfig: template: ‘<foo-page/>’ Routingconfig: template: ‘<bar-page/>’
  • 12. Other advantages ● No scope soup ● Nice hierarchy view ● Single responsability ● No more absolute paths ● Easier to reason about ● Easier to refactor ● Easier to upgrade to ng2
  • 13. What about attribute-directives? ● Let’s call them behaviors from now ● They add some logic to existing or custom components ● Separate them from your components folder
  • 14. DEMO
  • 17. Any rules of thumb?
  • 20. Keep them dumb where possible...
  • 21. Dumb component Smart component (container) Doesn’t know about the application Knows about the application Doesn’t do data fetching Does data fetching Main purpose is visualization Interacts the application Reusable Not reusable Only communicates with its direct parent Passes state and data to its children Doesn’t do state management Does state management
  • 24. State management ● State is very hard to manage in SPA’s ● State can be ○ data: results from REST calls ○ “sidebar is collapsed” or “spinner is active” ○ Which tab is currently active
  • 25. State management ● 3 types of state ○ Data state ○ Application state ○ Inner state (e.g value of textbox) We don’t have to persist nor manage that
  • 26. Why is it so hard to manage? ● 1-way databinding and 2-way databinding ● javascript references that are being broken and sometimes kept ● We can mutate the data in a million different ways ● No structure ● Data flows in different directions
  • 27. application state & logic state & logic state & logic state & logic state & logic state & logic state & logic state & logic state & logic state & logic Without flux
  • 28. 1 2 5 6 3 7 8 4 9 10 11 Without flux
  • 29. 1 2 5 6 3 7 8 4 9 10 11 I changed Without flux
  • 30. 1 2 5 6 3 7 8 4 9 10 11 I changed So did I Without flux
  • 31. 1 2 5 6 3 7 8 4 9 10 11 I changed So did I My changes should reflect 6 and 4 Without flux
  • 32. 1 2 5 6 3 7 8 4 9 10 11 I changed So did I My changes should reflect 6 and 4 I have to subscribe before 8 sends a message Without flux
  • 33. 1 2 5 6 3 7 8 4 9 10 11 I changed So did I My changes should reflect 6 and 4 I have to subscribe before 8 sends a message I’m sending an event upwards Without flux
  • 34. 1 2 5 6 3 7 8 4 9 10 11 I changed So did I My changes should reflect 6 and 4 I have to subscribe before 8 sends a message I’m sending an event upwards I’m sending events downwards Without flux
  • 35. 1 2 5 6 3 7 8 4 9 10 11 I changed So did I My changes should reflect 6 and 4 I have to subscribe before 8 sends a message I’m sending an event upwards Without flux I’m sending events downwards
  • 36. 1 2 5 6 3 7 8 4 9 10 11 I changed So did I My changes should reflect 6 and 4 I have to subscribe before 8 sends a message I’m sending an event upwards I get my data from model x and I can update it here I get my data from model z Without flux I’m sending events downwards I get my data from model y
  • 37. 1 2 5 6 3 7 8 4 9 10 11 I changed So did I My changes should reflect 6 and 4 I have to subscribe before 8 sends a message I’m sending an event upwards I get my data from model x and I can update it here I get my data from model z Without flux My data is passed by twoway binding I’m sending events downwards I get my data from model y My data is passed by oneway binding My data is passed by twoway binding
  • 38. Where do those states/events come from?
  • 39. Who updated my state??
  • 42. Flux helps with that ● Brings structure in data flow ● Not a framework but an architecture by facebook ● Unidirectional dataflow, oneway databinding ● Data flows from the top down ● Easier to reason about state
  • 43. ● Action ○ Has an action type and a payload ● Dispatcher ○ Dispatches the actions to the store ● Store ○ Contains state ● View Components
  • 44. ● The unidirectional dataflow makes it easy to reason about
  • 45. I use Redux! Redux is based on flux, but it’s easier
  • 46. Redux ● Written by Dan Abramov (Facebook) ● Easier to use and less bloat ● Only has one store!! ● Completely Immutable data structure ● Uses reducers (pure functions) ● Flux approves
  • 48. 1 2 5 6 3 7 8 4 9 10 11 Me too Me too Me too Me too STORE I only send actions upwards to the store I’m the single- source-of-truth in your application!! ;-)
  • 49. 1 2 5 6 3 7 8 4 9 10 11 Me too Me too I’m dumb I’m dumb I’m dumb I’m dumb I’m dumb I’m dumb STORE Me too I only send actions upwards to the store Me too I’m the single- source-of-truth in your application!! ;-) Dumb components only notify their direct parents! No state management needed here :-)
  • 50. What’s different? ● We have one single source of truth: the store ● We don’t update state ourselves anymore, the store handles all the state of our application ● State is immutable ● Actions are always sent upwards
  • 51. What’s different? ● Dumb components don’t do state management ● State is being updated by pure functions (reducers) ● When the store is updated it notifies all the smart components
  • 53. Actions ● Actions have a type and a payload ● Keep the types together, gives clear overview
  • 55. Reducers ● Pure functions ● reducer(state: MyState, action: Action): MyState ● they update the state ● Completely immutable
  • 58. Middleware ● Easy logging, debugging ● Reproducible action state (pushable to server) ● Timetraveling with redux-devtools (requires react to be bundled in the angular project)
  • 59. Check it out ● egghead.io course (Free) ○ https://egghead.io/series/getting-started-with-redux
  • 60. Special thanks to ● Kwinten Pisman (@kwintenp) ● Jurgen Van de Moere (@jvandemo)
  • 62. One more thing Angular2, rxjs, redux, @ngrx/store, Typescript, webpack http://workshop.brecht.io @brechtbilliet Workshop June 2016