diff --git a/README.md b/README.md index 959028d0d..e0bfe7e9b 100644 --- a/README.md +++ b/README.md @@ -1,60 +1,39 @@ # redux-saga -[![Join the chat at https://gitter.im/yelouafi/redux-saga](https://badges.gitter.im/yelouafi/redux-saga.svg)](https://gitter.im/yelouafi/redux-saga?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - [![npm version](https://img.shields.io/npm/v/redux-saga.svg?style=flat-square)](https://www.npmjs.com/package/redux-saga) +[![Join the chat at https://gitter.im/yelouafi/redux-saga](https://badges.gitter.im/yelouafi/redux-saga.svg)](https://gitter.im/yelouafi/redux-saga?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![npm version](https://img.shields.io/npm/v/redux-saga.svg?style=flat-square)](https://www.npmjs.com/package/redux-saga) -An alternative Side Effects middleware (aka Asynchronous Actions) for Redux applications. -Instead of dispatching Thunks which get handled by the `redux-thunk` middleware, you -create *Sagas* to gather all your Side Effects logic in a central place. +An alternative Side Effects middleware (aka Asynchronous Actions) for Redux applications. Instead of dispatching Thunks which get handled by the `redux-thunk` middleware, you create *Sagas* to gather all your Side Effects logic in a central place. This means application logic lives in 2 places: - Reducers are responsible for handling state transitions between actions. - - Sagas are responsible for orchestrating complex/asynchronous operations. -Sagas are created using Generator functions. If you're not familiar with them you may find -[some useful links here.](http://yelouafi.github.io/redux-saga/docs/ExternalResources.html) +Sagas are created using Generator functions. If you're not familiar with them you may find [some useful links here.](http://yelouafi.github.io/redux-saga/docs/ExternalResources.html) -Unlike Thunks which get invoked on every action by Action Creators, Sagas are fired only -once at the start of the application (but startup Sagas may fire other Sagas dynamically). -They can be seen as Processes running in the background. Sagas watch the actions dispatched -to the Store, then decide what to do based on dispatched actions: Either making an asynchronous -call (like an AJAX request), dispatching other actions to the Store, or even starting other -Sagas dynamically. +Unlike Thunks which get invoked on every action by Action Creators, Sagas are fired only once at the start of the application (but startup Sagas may fire other Sagas dynamically). They can be seen as Processes running in the background. Sagas watch the actions dispatched to the Store, then decide what to do based on dispatched actions: Either making an asynchronous call (like an AJAX request), dispatching other actions to the Store, or even starting other Sagas dynamically. -In `redux-saga` all the above tasks are achieved by yielding **Effects**. Effects are simply -JavaScript Objects containing instructions to be executed by the Saga middleware (As an analogy, -you can see Redux actions as Objects containing instructions to be executed by the Store). -`redux-saga` provides Effect creators for various tasks like calling an asynchronous function, -dispatching an action to the Store, starting a background task or waiting for a future action -that satisfies a certain condition. +In `redux-saga` all the above tasks are achieved by yielding **Effects**. Effects are simply JavaScript Objects containing instructions to be executed by the Saga middleware (As an analogy, you can see Redux actions as Objects containing instructions to be executed by the Store). `redux-saga` provides Effect creators for various tasks like calling an asynchronous function, dispatching an action to the Store, starting a background task or waiting for a future action that satisfies a certain condition. -Using Generators, `redux-saga` allows you to write your asynchronous code in a simple -synchronous style. Just like you can do with `async/await` functions. But Generators -allow some things that aren't possible with `async` functions. +Using Generators, `redux-saga` allows you to write your asynchronous code in a simple synchronous style. Just like you can do with `async/await` functions. But Generators allow some things that aren't possible with `async` functions. -The fact that Sagas yield plain Objects makes it easy to test all the logic inside your Generator -by simply iterating over the yielded Objects and doing simple equality tests. +The fact that Sagas yield plain Objects makes it easy to test all the logic inside your Generator by simply iterating over the yielded Objects and doing simple equality tests. -Furthermore, tasks started in `redux-saga` can be cancelled at any moment either manually -or automatically by putting them in a race with other Effects. +Furthermore, tasks started in `redux-saga` can be cancelled at any moment either manually or automatically by putting them in a race with other Effects. # Getting started ## Install -``` -npm install --save redux-saga +```sh +$ npm install --save redux-saga ``` -Alternatively, you may use the provided UMD builds directly in the `