Posts

Showing posts from July, 2017

Introduction to Redux-Saga

Image
Introduction In this article I am going to introduce you to redux-saga [1]. Redux-saga is a library that aims to manage application side effects.






The mental model is that a saga is like a separate thread in your application that's solely responsible for side effects. redux-saga is a redux middleware, which means this thread can be started, paused and cancelled from the main application with normal redux actions, it has access to the full redux application state and it can dispatch redux actions as well [1].

It uses an ES6 feature called Generators to make those asynchronous flows easy to read, write and test. I thoroughly recommend you to read more about generators before getting into sagas.

Workshop Well, we are going to implement a simple application using redux-saga this time. The basic scaffolding of our app once built would be like this.



You may find the source code of this project on github [2]. Let me just show you the sagas first. Here’s the code for our sagas.


It uses E…