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

Redux for Maintainable Sites

Redux for Maintainable Sites

Slides for my lightning talk at the AWeber open house on Thur., Nov 10, 2016. Here I give a quick overview of Redux, what the stack kind of looked like before moving to it, some pros and cons of the technology, and lastly some bonus material on some ideas I've been thinking about with regard to making complex actions more pure to work with.

Jim Fitzpatrick

November 10, 2016
Tweet

More Decks by Jim Fitzpatrick

Other Decks in Technology

Transcript

  1. How we got here • Had an untestable*, unmaintainable* monolith

    • Began transition to SOA / microservices • Broke up UI into multiple SPAs ◦ Inital SPAs implemented with homebrew MVC ◦ Moved to Backbone
  2. Backbone pain points • Tight coupling between views and behavior

    ◦ Difficult to pivot • Event spaghetti ◦ Difficult to maintain • Difficult to make reusable views
  3. Redux is... “A predictable state container for JS apps.” •

    An evolution of Flux • Uni-directional data flow • Heavily influenced by Elm and functional programming
  4. Redux in a nutshell: the store • Global state tree

    for a Redux app • Single source of truth for all UI and data state
  5. Redux in a nutshell: actions • State can only be

    changed by emitting actions • Actions describe what happened
  6. Redux in a nutshell: reducers • Reducers specify how state

    is updated, given a current state and an action
  7. Redux pros (from my perspective) • Every aspect of the

    application is segregated ◦ State, actions, rendering logic, etc. • Rendering becomes a function from state to UI ◦ Actual rendering engine is an implementation detail • Core components are pure functions • Actions tell a story • Middleware for extension and customization • Amazing community / developer tooling
  8. Redux pros (from my perspective) • Every aspect of the

    application is segregated ◦ State, actions, rendering logic, etc. • Rendering becomes a function from state to UI ◦ Actual rendering engine is an implementation detail • Core components are pure functions • Actions tell a story • Middleware for extension and customization • Amazing community / developer tooling
  9. Redux pros (from my perspective) • Every aspect of the

    application is segregated ◦ State, actions, rendering logic, etc. • Rendering becomes a function from state to UI ◦ Actual rendering engine is an implementation detail • Core components are pure functions • Actions tell a story • Middleware for extension and customization • Amazing community / developer tooling
  10. Redux pros (from my perspective) • Every aspect of the

    application is segregated ◦ State, actions, rendering logic, etc. • Rendering becomes a function from state to UI ◦ Actual rendering engine is an implementation detail • Core components are pure functions • Actions tell a story • Middleware for extension and customization • Amazing community / developer tooling
  11. Redux pros (from my perspective) • Every aspect of the

    application is segregated ◦ State, actions, rendering logic, etc. • Rendering becomes a function from state to UI ◦ Actual rendering engine is an implementation detail • Core components are pure functions • Actions tell a story • Middleware for extension and customization • Amazing community / developer tooling
  12. Redux pros (from my perspective) • Every aspect of the

    application is segregated ◦ State, actions, rendering logic, etc. • Rendering becomes a function from state to UI ◦ Actual rendering engine is an implementation detail • Core components are pure functions • Actions tell a story • Middleware for extension and customization • Amazing community / developer tooling
  13. Redux cons • Prone to boilerplate / verbosity • Non-fractal

    • Generally requires ancillary libraries • Requires some learning
  14. Redux cons • Prone to boilerplate / verbosity • Non-fractal

    • Generally requires ancillary libraries • Requires some learning
  15. Redux cons • Prone to boilerplate / verbosity • Non-fractal

    • Generally requires ancillary libraries • Requires some learning
  16. Redux cons • Prone to boilerplate / verbosity • Non-fractal

    • Generally requires ancillary libraries • Requires some learning