Learning Redux-Saga #javascript #reactjs #redux #redux-saga

Learning Redux-Saga  #javascript #reactjs #redux #redux-saga

  • Redux-saga is a Redux middleware to handle side effects, mainly the asynchronous actions which change the state.
  • A saga is a generator function that can run asynchronous actions indefinitely like a thread in the application.
  • On the other hand, Redux-saga uses the generators which can pause, resume, and interact with the asynchronous actions by using generators.
  • Each of the following functions will return a saga effect which is an object containing instructions of what/how the action should be executed by the saga middleware.
  • takeEvery – – Resolve the effect with the result of each time that the action is received.

Redux-saga is a Redux middleware to handle side effects, mainly the asynchronous actions which change the state. A saga is a generator function that can run asynchronous actions indefinitely like a thread in the application.
Continue reading “Learning Redux-Saga #javascript #reactjs #redux #redux-saga”

Learning Redux-Saga #javascript #reactjs #redux #redux-saga

Learning Redux-Saga  #javascript #reactjs #redux #redux-saga

  • Redux-saga is a Redux middleware to handle side effects, mainly the asynchronous actions which change the state.
  • A saga is a generator function that can run asynchronous actions indefinitely like a thread in the application.
  • On the other hand, Redux-saga uses the generators which can pause, resume, and interact with the asynchronous actions by using generators.
  • Each of the following functions will return a saga effect which is an object containing instructions of what/how the action should be executed by the saga middleware.
  • takeEvery – – Resolve the effect with the result of each time that the action is received.

Redux-saga is a Redux middleware to handle side effects, mainly the asynchronous actions which change the state. A saga is a generator function that can run asynchronous actions indefinitely like a thread in the application.
Continue reading “Learning Redux-Saga #javascript #reactjs #redux #redux-saga”

Using Saga To Accumulate And Deduplicate Redux Actions

  • GET /users/789 GET /users/456 GET /users/735 …
  • keys ( ids [ resource ]) }, }); delete ids [ resource ]; delete tasks [ resource ]; } function * accumulate ({ payload }) { const { id , resource } = payload ; if ( !
  • GET /posts HTTP 1.1 OK [ { id: 93, title: ‘seatae soluta recusante’, author_id: 789, }, { id: 124, title: ‘commodi ulam sint et’, author_id: 456 }, { id: 125, title: ‘consequatur id enim sint’, author_id: 735 }, …
  • The accumulate() function adds the id from the payload to an ids object that’s in the middleware closure, with a trick to deduplicate ids.
  • Redux Saga allowed us to keep the component logic simple (each component dispatches one single action), and to add sophisticated side effects in the controller part of the application.


Published on 18 October 2016

by Fran├žois Zaninotto

with tags ReactJS admin-on-rest Redux

Continue reading “Using Saga To Accumulate And Deduplicate Redux Actions”