###### Table of Contents
- [[#About]]
- [[#Saga mental model]]
- [[#Concepts]]
- [[#Declarative Effects]]
# About
While the basics of Redux are pretty straightforward and easy to reason about, things get more complicated when we need to handle async actions (often called side effects in functional programming).
To address this problem, Redux suggests using middlewares (especially [thunk middleware](https://github.com/gaearon/redux-thunk)). Basically the idea is, if you need to trigger side effects, use an action creator: a function that returns a function that can do any async call needed and dispatch whatever action you want.
Using this approach can quickly lead to complex and very difficult to test actions creators. That’s where redux-saga comes in.
[More info](https://riad.blog/2015/12/28/redux-nowadays-from-actions-creators-to-sagas/)
___
`redux-saga` is a library that aims to make application side effects (i.e. asynchronous things like data fetching and impure things like accessing the browser cache) easier to manage, more efficient to execute, easy to test, and better at handling failures.
## Saga mental model
A saga is like a separate thread in your application that's solely responsible for side effects.
`redux-saga` is a redux middleware, which means this thread can be started, paused and cancelled from the main application with normal redux actions, it has access to the full redux application state and it can dispatch redux actions as well.
It uses an ES6 feature called Generators to make those asynchronous flows easy to read, write and test.
## Concepts
### Declarative Effects
In `redux-saga`, Sagas are implemented using Generator functions.
To express the Saga logic, we yield plain JavaScript Objects from the Generator. We call those Objects [_Effects_](https://redux-saga.js.org/docs/api/#effect-creators).
An Effect is an object that contains some information to be interpreted by the middleware. You can view Effects like instructions to the middleware to perform some operation (e.g., invoke some asynchronous function, dispatch an action to the store, etc.).
To create Effects, you use the functions provided by the library in the `redux-saga/effects` package.
#### More info
[Some website](https://test.com)
___
**Tags**: