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

Modernizing Legacy Codebases With Redux

Modernizing Legacy Codebases With Redux

These are the slides from the talk I gave at ReactNL on October 13, 2016, and at Reactathon on March 7, 2017.

Justin Bachorik

October 13, 2016
Tweet

More Decks by Justin Bachorik

Other Decks in Programming

Transcript

  1. ?

  2. const player = (state, action) => { switch (action.type) {

    case Actions.TOGGLE_PLAY: return { ...state, isPlaying: !state.isPlaying }
  3. const myMiddleware = store => next => action => {

    // @todo: something useful? return next(action); };
  4. const myMiddleware = ({ dispatch, getState }) => next =>

    action => { // @todo: something useful? return next(action); };
  5. const outgoing = ({ dispatch, getState }) => next =>

    action => { // @todo: something useful? return next(action); };
  6. const outgoing = ({ getState }) => next => action

    => { // @todo: something useful? return next(action); };
  7. const outgoing = ({ getState }) => next => action

    => { if (action.type === Actions.TOGGLE_PLAY) { $('body').toggleClass('is-playing'); } return next(action); };
  8. const incoming = ({ dispatch, getState }) => next =>

    action => { // @todo: something useful? return next(action); };
  9. const incoming = ({ dispatch }) => next => action

    => { // @todo: something useful? return next(action); };
  10. const incoming = ({ dispatch }) => next => action

    => { if (!inited) { $('document').on('stationChanged', station => dispatch( { type: Actions.STATION_CHANGED, station } )); inited = true; }