Feb 25, 2017 · 1 min read
Fantastic article, nothing better than a good comparison. You did an excellent job of keeping it distraction free, which is extremely hard to do when discussing this topic 👏.
Each have their PROS and CONS, so ideally you would use each based on the use case. Unfortunately, having multiple middleware in the same application can cause a lot of confusion in teams, so it’s often best to pick one for consistency even though it can come at a cost (e.g. complexity or boilerplate etc).
- Promise Middleware is insanely good for calling RESTful APIs, but can fall short for other things.
- Thunks are a jack of all trades, good at everything, but require mocking for testing.
- Saga’s can do it all and are super easy to test, but have a learning curve and require some boilerplate.
- Observables are powerful (cancel async actions), but like Saga’s come with a learning curve.
It would be amazing if you had time to do a “part 2” diving into the testing of each middleware. This often play’s a huge role in choosing one library or pattern over another.
Thanks for the great article, looking forward to reading more from you.