javascript – Suppress API call in Redux Saga based on a timer

I have an API that provides data that is updated at an unusual time, approximately once every 2½ minutes on average. Assuming it is okay to get only every 2½ minutes or less, I would like to build a saga (use redux-saga) so that it does not do anything if it is not yet time to make a call to the API. The code I came up with is quite simplistic (API error handling is omitted):

import {select, put, call} from "redux-saga / effects";

const FETCH_INTERVAL = 1000 * 60 * 60 * 2.5;

function * fetchApiSaga (apiUrl) {
// get data from the store
const data = select (state => state.theDataWeNeed);

// tell the user that we are about to search for data

// if it recovered 2.5 years ago or earlier, it recovers again
if (! data || new Date () -! data.lastFetchedAt> FETCH_INTERVAL) {
response const = performance call (apiUrl);

// tell the user that we now have new API data
put (REWRITE_DATA, answer);
} else {
// tell the user that we only reuse old data

Now, I have two questions:

  1. Is this an idiomatic way to suppress consecutive actions in Redux Saga based on time?
  2. Is this Redux Saga idiomatic if the generator function selectIs the store and therefore not pure?

Download game Candy Crush Saga.

Press the "Download now" button to download Candy Crush Saga game installer
The whole process will only take a few minutes.



– Title: Candy Crush Saga game
– Type of download: security (without torrent / without virus)
– Status file: clean (as of the last analysis)
– File size: undefined
– Price: free
– Special requirements: do not




With these puzzles, Candy Crush Saga is a much slower game than its competitors. What makes the game even more strategic are the various special sweets you can create. When activated, they tend to cause a lot of damage to the board, eliminating entire rows of candy or blowing up all the treats of a specific color.
Spring has emerged in the Candy Crush saga, change and combine colorful candies to unwrap surprises in the game! Start playing Candy Crush Saga today, loved by millions of players around the world. With over one trillion levels played, this sweet 3-in-a-row puzzle game is one of the most popular mobile games of all time! Change and combine the candies in this divine puzzle adventure to progress …
Free download of Candy Crush Saga games: Candy Crush Saga game guide, Candy Crush Saga game guide, Candy Crush Saga game cheats and many more.
Play Candy Crush Saga online at! Change and combine your way through hundreds of tasty levels in this divine puzzle game! Sweet!
Also, if you want to download the game Candy Crush Saga on a PC (All Windows / Laptop), you must download the emulator (Bluestacks or Alternative) before downloading [Candy Crush Saga Game]. Free download of the game Candy Crush Saga for PC (Windows): start playing the Candy Crush saga today, loved by millions of players around the world.
Download this game from Microsoft Store for Windows 10, Windows 10 Mobile, Windows Phone 8.1, Windows Phone 8, Windows 10 Team (Surface Hub), HoloLens. Watch screenshots, read the latest customer reviews and compare the ratings of the Candy Crush series.
Candy Crush Saga: we all love to play our favorite video games on smartphones. Some people are addicted to some of their favorite games. That way, I'll share about one of the most popular and addicted games of Candy Crush Saga for PC in this publication today. Candy Crush Saga is the most popular and the most loved Android game. . Actually, the game of saga Candy Crush is a game of three …
Download Candy Crush Soda Saga for free now. It's Sodalicious! Candy Crush Soda Saga is a new game from the creators of the legendary Candy Crush Saga. New candies, more divine combinations and challenging game modes overflowing with purple soda! The game Candy Crush Soda Saga is completely free, but some elements of the game, such as movements or additional lives, will require payment.
Ready to play Candy Crush Jelly Saga? Visit and get caught. Change, match, win! … with people from all over the world playing one or more of our games. We have developed more than 200 fun titles, offering games that are enjoyed all over the world.
The successful game is now available in the full flash version and you can play it here without registration or Facebook account. Candy Crush Saga is a Bejeweled game with hundreds of levels and many different modes: score to reach, limited number of moves, ingredients to go through the bottom of the screen, eliminate all the jelly …
Candy Crush Saga Review – Download Free Games
Candy Crush Saga – Apps on Google Play
Download game Candy Crush Saga – Free downloads and
Download game Candy Crush Saga for PC (Windows 10 | Mac) – IOS
Get Candy Crush Saga – Microsoft Store
Download game Candy Crush Saga for PC (Windows 7/8 / XP and Mac)
Candy Crush Soda Saga – Apps on Google Play
Find us at: – – Play the most popular and fun games
Candy Crush Saga – Play Free Online Games
Download game Candy Crush Saga.
Move to the free download
disk discharge box
download windows 10 activator exe
Microsoft Office free download
virtual dj download 7
Microsoft Office Mac download
mac imovie free download
download titanic 2 jack is back
manual download of ios 10
Dx11 feature level 11.0 download
download ios for ipad
the medieval sims download
Bass tab pdf download for free
Office 2013 Mac download
Captain Marvel movie download free

javascript: when using Redux / Redux-Saga, should the JWTs be configured in the action / saga creators?

Almost all blog posts I've found around generic authentication handling using JWT in a React / Redux / Saga application do the same thing, which is storing JWT in local storage, in the action / saga.

For example:

Example A (redux-saga):

* authorize function ({payload: {login, password}}) {
options const = {
body: JSON.stringify ({login, password}),
method: & # 39; POST & # 39 ;,
headers: {& # 39; Content-Type & # 39 ;: & # 39; application / json & # 39;}

try {
const {token} = call performance (fetchJSON, & # 39; / login & # 39 ;, options);
performance set ({type: AUTH_SUCCESS, payload: token});
localStorage.setItem (& # 39; token & # 39 ;, token);
} capture (error) {
leave a message;
switch (error.status) {
case 500: message = & # 39; Internal server error & # 39 ;; break;
case 401: message = & # 39; invalid credentials & # 39 ;; break;
default: message = & # 39; Something went wrong & # 39 ;;
put performance ({type: AUTH_FAILURE, payload: message});
localStorage.removeItem (& # 39; token & # 39;);

function * saga () {
takeLatest performance (AUTH_REQUEST, authorize);

Example B (redux):

login function (username, password) {
const requestOptions = {
method: & # 39; POST & # 39 ;,
headers: {& # 39; Content-Type & # 39 ;: & # 39; application / json & # 39;},
body: JSON.stringify ({username, password})

Fetch return (`$ {config.apiUrl} / users / authenticate`, requestOptions)
.then (handleResponse)
.then (user => {
// successful logon if there is a jwt token in the response
if (user.token) {
// store the details of the user and the jwt token in the local storage to keep the user connected between the updates of the page
localStorage.setItem (& # 39; user & # 39 ;, JSON.stringify (user));

Returned user

logout () {function
// remove the user from local storage to close the user's session
localStorage.removeItem (& # 39; user & # 39;);

Now, aside from the storage of JWT in the local storage, what worries me is the adjustment of the state within the action / creator of the action, instead of a reducer.

As I understand it, the creators of actions / sagas should be used only to determine the data that will be used, and it depends on the reducers to store / preserve the data.

Why, then, does it seem that everyone overlooks the use of redux as the state of the application when it comes to authentication?

Redux LOAD / SUCCESS / ERROR pattern – when using the redux saga

In a typical web application, we commonly have to deal with the LOADING / SUCCESS / ERROR problem, which is that:

  • When I make a backend request I want to show a loading cursor, maybe disable some buttons.
  • When the request finishes correctly, I want to show the data.
  • When the request ends with an error, I want to show or handle the error.

If you're not careful, this can lead to a spaghetti code, especially if you're doing things like having two requests running at the same time, and managing that when one request ends, it does not stop the load cursor for the other. Article, for example.

Only for redux. I found that this solution works quite well.

Basically, three actions are defined:


and then it has a generic reducer that will intercept all the requests and establish in its state of redux the state of charge and error, for that particular type of request (in this case GET_FOO).

Then you can select the load or error status in the component that needs it:

const loadingSelector = createLoadingSelector (['GET_FOO']);

const mapStateToProps = (state) => ({isFetching: loadingSelector (state)});

My question is: if I am using redux-saga, this pattern still applies well, or does redux-saga already solve this problem?