DEV Community

Discussion on: Asynchronous with Redux Sagas

Collapse
 
chrisachard profile image
Chris Achard

Nice overview of sagas!

When using them on real world projects, I've sometimes found it a bit confusing to reason about the fact that sagas can be "long running" - so a saga may be waiting for an event for a long time, and then fire later - and it would sometimes be a bit tricky to really track down what happened.

Any advice / tips for handling that? Thanks!

Collapse
 
irmerk profile image
Jolene Langlinais

Thank you!

Are you referring to data you are fetching inside a generator function? If so, are you yielding it?

If you're yielding, you can take advantage of the next method. The generator function is acting as an iterator, and you can return the next element in a sequence by invoking next() on the invoked generator (generator().next()). Since this iteration and sort of internal state that the generator maintains, you can stop at any point to see what the state is.

Collapse
 
chrisachard profile image
Chris Achard

Ah, perhaps using 'next()' was part of the puzzle I was missing. Thanks! I'm going to go and check that out.

Thread Thread
 
irmerk profile image
Jolene Langlinais

Great! Yes, and here's a resource I found helpful on the subject by Rajesh Babu.