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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Darpan Kakadia
October 25, 2017
Technology
290
0
Share
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
【PHPカンファレンス小田原2026】Webアプリケーションエンジニアにも知ってほしい オブザーバビリティ の本質
fendo181
0
590
今年60歳のおっさんCBになる
kentapapa
1
370
昔はシンプルだった_AmazonS3
kawaji_scratch
0
170
Data Hubグループ 紹介資料
sansan33
PRO
0
2.9k
終盤で崩壊させないAI駆動開発
j5ik2o
1
730
サイバーフィジカル社会とは何か / What Is a Cyber-Physical Society?
ks91
PRO
0
160
AIがコードを書く時代の ジェネレーティブプログラミング
polidog
PRO
3
720
JOAI2026講評会資料(近藤佐介)
element138
1
110
Azure Lifecycle with Copilot CLI
torumakabe
3
680
あるアーキテクチャ決定と その結果/architecture-decision-and-its-result
hanhan1978
2
590
Zero-Downtime Migration: Moving a Massive, Historic iOS App from CocoaPods to SPM and Tuist without Stopping Feature Delivery
kagemiku
0
230
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
3k
Featured
See All Featured
Optimizing for Happiness
mojombo
378
71k
Faster Mobile Websites
deanohume
310
31k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
310
Being A Developer After 40
akosma
91
590k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
10k
Believing is Seeing
oripsolob
1
110
How to Ace a Technical Interview
jacobian
281
24k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
220
Embracing the Ebb and Flow
colly
88
5k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
130
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
240
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
760
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