Skip to content

Commit

Permalink
side effects & async transactions demistified
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkis committed Feb 19, 2016
1 parent 2b433f3 commit 9df398e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ redux-saga-rxjs

## Introduction

### Redux is great, side-effects are problematic
### Redux is great, asynchronous transactions are problematic

### What is Saga pattern?
Saga is a pattern for orchestrating long running transactions... TODO
Expand Down Expand Up @@ -73,8 +73,9 @@ const reducer = (appState, { type }) {

### What's the relation between Saga pattern and Side effects?

So why people say that Saga is a great pattern for Side effects? API call is a good example of side effect - you'll probably have one action (`API_REQUESTED`) dispatched when user clicks the button to load data which presumably display loading spinner and another action to process the response (`API_FINISHED`) and this is all in single long running transaction which Saga can handle.
So why people say that Saga is a great pattern for Side effects? Let's take an API call as example - you'll probably have one action (`API_REQUESTED`) dispatched when user clicks the button to load data, which presumably displays loading spinner and another action to process the response (`API_FINISHED`) and this is all in single, long running asynchronous transaction which Saga can handle.

We need to distinguish between Side effects and Asynchronous transaction. The former stands for some effect which is not the primary goal of the calling function (mutation of some external state / calling XHR / logging to console...) while the latter stands for asynchronous sequence of actions which is some logical group (transaction). Saga solves the latter, it's just an implementation detail that it's capable of solving side effects. We could still say that it should be forbidden to perform side effects in Sagas as it is in Reducers - just a minor implementation detail.

## Usage

Expand Down

0 comments on commit 9df398e

Please sign in to comment.