Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Async in Redux
Search
Darpan Kakadia
October 25, 2017
Technology
300
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Async in Redux
Slides from my talk at ReactiveConf 2017 on how to handle Async in Redux.
Darpan Kakadia
October 25, 2017
Other Decks in Technology
See All in Technology
やさしいA2A入門
minorun365
PRO
12
1.7k
NAB Show 2026 動画技術関連レポート / NAB Show 2026 Report
cyberagentdevelopers
PRO
0
170
AIソロプレナー時代に2ヶ月で20人増員した事業創造会社の開発組織の話
miyatakoji
0
600
現地で盛り上がった WWDC26 Keynote
zozotech
PRO
1
200
攻撃者視点で考えるDetection Engineering
cryptopeg
1
1.2k
protovalidate-es を導入してみた
bengo4com
0
170
2026.06.13_AI時代に事業会社が「SIer出身エンジニア」を求める理由 / Why Businesses Seek Engineers with a System Integrator Background in the AI Era
jumtech
0
1k
Djangoユーザが知っ得なPostgreSQL機能 - 設計の選択肢を増やす / Djang-use-PostgreSQL
soudai
PRO
1
230
AIっぽい文章を採点して人間らしく直すアプリを作ってみた
yama3133
2
130
AI駆動開発を通して感じた、 AI時代のデザイナーの役割変化
whisaiyo
0
240
2026 TECHFRESH 畢業分享會 - AI-Native 重塑軟體工程與虛擬講師
line_developers_tw
PRO
0
800
Agent Skills設計で柔軟性と硬さのバランスが難しい話
nassy20
0
120
Featured
See All Featured
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
160
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
570
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
380
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Design in an AI World
tapps
1
240
RailsConf 2023
tenderlove
30
1.5k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
200
Making Projects Easy
brettharned
120
6.7k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
360
Become a Pro
speakerdeck
PRO
31
6k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
Transcript
Async in Redux
Darpan Kakadia UI Engineer @Cleartrip @kakadiadarpan
Promises, Thunks or Sagas?
You need just one!
You need just one!
Redux saga is a library which helps you manage async
actions using ES6 generator functions. Redux Saga
import { delay } from 'redux-saga' import { put, takeEvery
} from 'redux-saga/effects' // Our worker Saga: will perform the async increment task export function* incrementAsync() { yield delay(1000) yield put({ type: 'INCREMENT' }) } // Our watcher Saga: spawn a new incrementAsync task on each INCREMENT_ASYNC export function* watchIncrementAsync() { yield takeEvery('INCREMENT_ASYNC', incrementAsync) }
import { delay } from 'redux-saga' import { put, takeEvery
} from 'redux-saga/effects' // Our worker Saga: will perform the async increment task export function* incrementAsync() { yield delay(1000) yield put({ type: 'INCREMENT' }) } // Our watcher Saga: spawn a new incrementAsync task on each INCREMENT_ASYNC export function* watchIncrementAsync() { yield takeEvery('INCREMENT_ASYNC', incrementAsync) }
import { delay } from 'redux-saga' import { put, takeEvery
} from 'redux-saga/effects' // Our worker Saga: will perform the async increment task export function* incrementAsync() { yield delay(1000) yield put({ type: 'INCREMENT' }) } // Our watcher Saga: spawn a new incrementAsync task on each INCREMENT_ASYNC export function* watchIncrementAsync() { yield takeEvery('INCREMENT_ASYNC', incrementAsync) }
Let’s see how Thunks compares with Saga?
function fetchData() { return dispatch => { axios .get("/data") .then(data
=> {dispatch({ type: "FETCH_SUCCESS", data });}) .catch(error => dispatch({ type: "FETCH_FAILED", error })); }; } Redux Thunk
function fetchData() { return dispatch => { axios .get("/data") .then(data
=> {dispatch({ type: "FETCH_SUCCESS", data });}) .catch(error => dispatch({ type: "FETCH_FAILED", error })); }; } Redux Thunk
function fetchData() { return dispatch => { axios .get("/data") .then(data
=> {dispatch({ type: "FETCH_SUCCESS", data });}) .catch(error => dispatch({ type: "FETCH_FAILED", error })); }; } Redux Thunk
function* fetchData() { try { const data = yield call(axios.get,
"/data"); yield put({ type: "FETCH_SUCCESS", data }); } catch (error) { yield put({ type: "FETCH_FAILED", error }); } } function* rootSaga() { yield* takeLatest("FETCH_DATA", fetchData); } Redux Saga
function* fetchData() { try { const data = yield call(axios.get,
"/data"); yield put({ type: "FETCH_SUCCESS", data }); } catch (error) { yield put({ type: "FETCH_FAILED", error }); } } function* rootSaga() { yield* takeLatest("FETCH_DATA", fetchData); } Redux Saga
function* fetchData() { try { const data = yield call(axios.get,
"/data"); yield put({ type: "FETCH_SUCCESS", data }); } catch (error) { yield put({ type: "FETCH_FAILED", error }); } } function* rootSaga() { yield* takeLatest("FETCH_DATA", fetchData); } Redux Saga
function* fetchData() { try { const data = yield call(axios.get,
"/data"); yield put({ type: "FETCH_SUCCESS", data }); } catch (error) { yield put({ type: "FETCH_FAILED", error }); } } function* rootSaga() { yield* takeLatest("FETCH_DATA", fetchData); } Redux Saga
Isn’t that just too much work?
Advantages of redux-saga
• Task cancellation Advantages of redux-saga
• Task cancellation • Race conditions Advantages of redux-saga
• Task cancellation • Race conditions • Throttling Advantages of
redux-saga
• Task cancellation • Race conditions • Throttling • Debouncing
Advantages of redux-saga
• Task cancellation • Race conditions • Throttling • Debouncing
• Retrying network calls Advantages of redux-saga
• Task cancellation • Race conditions • Throttling • Debouncing
• Retrying network calls • Undo actions Advantages of redux-saga
@kakadiadarpan