Let's think of the following saga:
function* mySaga(){
const x = yield call(getX)
}
In truth, the value of const x
is not directly assigned by the return value of call(getX())
, but rather by whatever is passed in mySaga.next(whatever)
when it is called.
I assume that redux-saga is smart enough to manage the saga in such a way that it calls the .next()
method with the result of the last promise yielded.
Is it, though?
How safe is it to just assume that x
is actually the result of getX()
?
How safe is it to just assume that x is actually the result of getX()
If the generator is being run by redux saga, then as long as getX
returns something (ie, it doesn't throw and doesn't go into an infinite loop) redux saga guarantees that the saga will be resumed with that return value, and thus assigned to x
.
If you manually step through the saga, then it will get whatever you manually insert in. About the only reason i can think for manually iterating a saga is to write a unit test, so this is not a concern you need to worry about if you're using redux saga as it was designed.