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.
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.
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!
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 invokingnext()
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.Ah, perhaps using 'next()' was part of the puzzle I was missing. Thanks! I'm going to go and check that out.
Great! Yes, and here's a resource I found helpful on the subject by Rajesh Babu.