You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes it's necessary and idiomatic to directly return the result of an effect. Using the yield-effects linter rule in this case motivates the usage of return yield effect() syntax which feels odd.
For generators in general, both yield and return expressions result in values being returned. Both are legit outputs. Sandwiching the extra yield inside there doesn't actually appear to be necessary. There's no reason to pause the generator before ending it. You can just end it. So return yield "works", but it seems strange for a linter to insist on. 🤔
This maybe doesn't come up for people because most generators probably primarily deal with yields. Note that return yield could have specialized uses in non-saga generators: https://stackoverflow.com/a/42309429
If I'm wrong about this I would be grateful for any clarification.
The text was updated successfully, but these errors were encountered:
Well, yield and return expressions both "return" values. One needs to distinguish between the keyword and the concept.
return yield is unnecessary in sagas because the yield returns the effect, but allows the generator to be restarted. But when we know that we're finishing the generator with return, there's no reason to restart. Why would we want to pause before finishing, when we could just finish? The inner yield is superfluous. It's like an extra wrapper.
Sometimes it's necessary and idiomatic to directly
return
the result of an effect. Using theyield-effects
linter rule in this case motivates the usage ofreturn yield effect()
syntax which feels odd.For generators in general, both
yield
andreturn
expressions result in values being returned. Both are legit outputs. Sandwiching the extrayield
inside there doesn't actually appear to be necessary. There's no reason to pause the generator before ending it. You can just end it. Soreturn yield
"works", but it seems strange for a linter to insist on. 🤔This maybe doesn't come up for people because most generators probably primarily deal with
yield
s. Note thatreturn yield
could have specialized uses in non-saga generators: https://stackoverflow.com/a/42309429If I'm wrong about this I would be grateful for any clarification.
The text was updated successfully, but these errors were encountered: