redux logic

Untitled

redux-thunk, redux-saga logic

Untitled

redux-thunk

redux-thunk 구현체

function createThunkMiddleware(extraArgument) {
  return ({ dispatch, getState }) => (next) => (action) => {
    if (typeof action === 'function') {
      return action(dispatch, getState, extraArgument);
    }

    return next(action);
  };
}

const thunk = createThunkMiddleware();
thunk.withExtraArgument = createThunkMiddleware;

export default thunk;

redux-thunk 예제코드

Untitled

Untitled

redux-saga

리액트/리덕스 애플리케이션의 side effect를 더 쉽고 좋게 만드는 것을 목적으로 하는 미들웨어 라이브러리

Generator

Untitled

https://react.vlpt.us/redux-middleware/10-redux-saga.html