DEV Community

Async React Basics with Redux-thunk & Redux-saga

Norbert Braun on October 08, 2018

I have lots of free time lately so I decided to play around a bit with React & Redux. If you want to write maintainable asynchronous code using...
Collapse
 
lexlohr profile image
Alex Lohr

Thanks for the nice article. Since you're already familiarized yourself with thunks and sagas, you should probably learn about epics in redux-observables. I find them a cleaner abstraction of side effects in redux than the other options. The only problem is that they are so powerful, you'll soon end up using epics for everything.

Collapse
 
benjamindaniel profile image
Benjamin Daniel

Everyone keeps recommending redux-observables, will definitely check it out.

Collapse
 
bnorbertjs profile image
Norbert Braun

Hi Alex, thanks for the hint I'll definitely check it out!

Collapse
 
adenforshaw profile image
Aden Forshaw

Awesome Article, great to see the Cat API being used to teach, thanks Norbert!

Collapse
 
bnorbertjs profile image
Norbert Braun

Thanks, Aden great api by the way :)

Collapse
 
jordanchristie profile image
Jordan Christie

Awesome stuff. When deciding between the two I chose Redux-Thunk just because it clicked faster. I've been curious about Saga lately, what's the advantage?

Collapse
 
bnorbertjs profile image
Norbert Braun

Hi Jordan, thank you!
I think the main advantage saga has over thunk is the testability. Generator functions return iterators. So you can pretty easily see, what's going on in your function by calling .next().

Here's an example to test sagas: redux-saga.js.org/docs/basics/Disp...

OR

redux-saga.js.org/docs/advanced/Te...

Collapse
 
sagar profile image
Sagar

In depth article on redux-thunk and redux-saga. Thanks for writing wonderful article.

Collapse
 
bnorbertjs profile image
Norbert Braun

Thanks, glad you like it. :)

Collapse
 
hdlinhit95 profile image
Lin

Wonderful article!
Thanks u

Collapse
 
chadsteele profile image
Chad Steele

I'd love it if you wanted to dissect my Redux one line replacement hook... useSync
dev.to/chadsteele/redux-one-liner-...