Redux Saga vs Thunk: What should you choose?

preview_player
Показать описание
In this video, we compare and contrast Redux Saga and Thunk.

———————————

for more algorithm explanations, tech discussions, and programming tutorials!

———————————

Hey there, my name’s EdRoh. On my channel, you will find common coding algorithms and/or interview questions (with explanations of course). I also provide tutorials and courses on other programming topics in Web Development including Javascript, React, HTML, CSS, TypeScript, Redux, Node, Progressive Web Apps, React Native, Flutter, etc.

No matter what level you are, whether you are already in the software engineering field, or are just beginning coding in bootcamp or being self taught, my first and foremost desire is to help you provide with the best teaching content and learning resource I possibly can. As someone who understands the struggles of switching careers, I hope I can help guide you into this difficult but rewarding journey into engineering.
Рекомендации по теме
Комментарии
Автор

9:30 you said setting up thunk gets messy. I disagree, it's because you've not structured the code properly for thunk. You're using .then (instead of using async await)and explicit returns and also actions as functions. Instead you'd dispatch the object directly. You can make the code look really neat with thunk.

KaranKumar-wbbn
Автор

Thank you for the clear explanation, I have been using Thunk this whole time and wanted to learn about Saga.
I'm pretty comfortable using thunk, I feel like it's better in some cases. But knowing saga have plenty built in feature makes me reconsider it for my future project :D

bagusamrullah
Автор

The big advantage of Redux Saga seems to be the built-in helper functions/effects. Other than that, it is difficult to see why:
> const response = yield call(fetch url);
is an improvement over:
> const response = await fetch(url);

Also, for a better comparison, I'd like to see a solution that didn't use ANY middleware. It would be interesting to compare readability to thunks and sagas. I suspect it would look a lot like your thunk code.

trevedhek
Автор

Instead of using .then why can we use async await for avoiding callback hell??

calwinstevepaul.k
Автор

Pretty clean tutorial!! Finally found a Saga / Thunk tutorial which explains things in a simple fashion.

SouravDey
Автор

Your videos are very enjoyable!
I learned a lot of sagas with you, thanks man. I used to have the same thought that you said "uhhh gotta learn more stuff" - but with time that went away and now I appreciate sagas :)

tubanami
Автор

I have a question maybe a little bit stupid, why can't we just use async await on a regular reducer and call again the reducer function if needed? why do we need to use a middleware? by the way great video

OscarRuiz-qlbt
Автор

You can also use async and await for one line of code in case of redux thunk .
And you can also use with axios.
One more thing is your video is helpful for all, thanks for making such type of video 👍

codewithabhishek
Автор

I'm glad I'm not the only one who prefers saga. But you could have used asyn await for thunk to give it a better fight chance.

geebsayshi
Автор

A very good one. I watched it cause there are no other videos on this subject with a source code

piotrekjazz
Автор

On 11.0 you try to prove that consecutive api calls may create a callback hell hence use Saga. Can we use the async/await there?

nikhilev
Автор

I believe that an engineer would benefit more by;
- using Thunks with async/await (avoiding callback hell),
- applying any async effects themselves (e.g. Throttling).

This could include using a lower level lib such as RxJS - which can be applied to more situations, outside of state management. As an engineers, learning how to handle async events is crucial to personal development, and will pay off in the long run.

stencil
Автор

good tutorial, you made redux-sage very simple :3

😇😇😇

AnNguyen-uvyc
Автор

Can't we use async await syntax for call back hell or dependency problem

amitthakur
Автор

Hm...so if we know how to use async await or Promise.all() then there is no need for saga right?

philippeb
Автор

Promise comes to avoid callback hell, then you start a promise hell, why? Just return the new promise and use its return in the next then.

lvendrame
Автор

u can use async/await also right?
what u did for saga

roshanlalsahu