A common abstraction: Effect
To generalize, triggering Side Effects from inside a Saga is always done by yielding some declarative Effect. (You can also yield Promise directly, but this will make testing difficult as we saw in the first section.)
What a Saga does is actually compose all those Effects together to implement the desired control flow. The most basic example is to sequence yielded Effects by putting the yields one after another. You can also use the familiar control flow operators (if
, while
, for
) to implement more sophisticated control flows.
We saw that using Effects like call
and put
, combined with high-level APIs like takeEvery
allows us to achieve the same things as redux-thunk
, but with the added benefit of easy testability.
But redux-saga
provides another advantage over redux-thunk
. In the Advanced section you'll encounter some more powerful Effects that let you express complex control flows while still allowing the same testability benefit.