Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Angular - Managing State with ngRx

Angular - Managing State with ngRx

Presentation at Cluj. RxJS powered state management for Angular applications, inspired by Redux

Jecelyn Yeen

March 17, 2018
Tweet

More Decks by Jecelyn Yeen

Other Decks in Programming

Transcript

  1. @JecelynYeen From Kuala Lumpur, Malaysia Google Developer Expert - Web

    technologies, Angular Software Architect @ Randstad
  2. Helpful when you have • complex state • multi-level component

    interactions • a standard way of handling state
  3. What we want? • State across pages (components) • list-page

    needs to access coffeeList and cart • cart-page needs to access coffeeList and cart • State across parent/child, multi-level components • header needs to access coffeeList and cart • pay needs to access coffeeList and cart
  4. What we really really want? • Single source of truth

    - same/consistent state across all components • Predictability - standard way of updating the state (e.g. like sql update statement), immutability / pure function
  5. Action can be a class or an object Always with

    two properties: type, payload Object Class
  6. What is ngrx effects? • Imagine ngrx effects is a

    spy • It listen to all actions • Filter the actions that it finds useful • Then, firing / dispatching new action
  7. Component State Action dispatch Reducer new state render sent to

    Effect sent to Action Store Effects service server