Redux Middleware- The differences between Redux-thunk and Redux-saga
Introduction
In redux, we always need middleware to help us to handle the asynchronous operations or other side effects.
The most popular middlewares are Redux-thunk and Redux-saga.
This topic notes the differences between Redux-thunk and Redux-saga for using. We will discuss the following items.
- Overview
- Concepts
- Roles and usages
- Libraries
- Implementations
Overview
Definitions
- Redux-thunk (the definitions from npmjs.com)
Redux Thunk middleware allows you to write action creators that return a function instead of an action. The thunk can be used to delay the dispatch of an action, or to dispatch only if a certain condition is met.
- Redux-saga (the definitions from redux-saga.js.org)
redux-saga
is a library that aims to make application side effects (i.e. asynchronous things like data fetching and impure things like…