- Notifications
You must be signed in to change notification settings - Fork121
A library that ports Elm's effect system to Redux
License
MIT, Unknown licenses found
Licenses found
redux-loop/redux-loop
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A port of theElm Architecture to Redux that allows you to sequence your effects naturally and purely by returning them from your reducers.
Isn't it incorrect to cause side-effects in a reducer?
Yes! Absolutely.
Doesn't redux-loop put side-effects in the reducer?
It doesn't. The values returned from the reducer when scheduling an effect withredux-loop onlydescribe the effect. Calling the reducer will not cause theeffect to run. The value returned by the reducer is just an object that thestore knows how to interpret when it is enhanced by redux-loop. You can safelycall a reducer in your tests without worrying about waiting for effects to finishand what they will do to your environment.
What are the environment requirements for redux-loop?
redux-loop requires polyfills for ES6Promise andSymbol to be included ifthe browsers you target don't natively support them.
Having used and followed the progression of Redux and the Elm Architecture, andafter trying other effect patterns for Redux, we came to the followingconclusion:
Synchronous state transitions caused by returning a new state from the reducerin response to an action are just one of all possible effects an action canhave on application state.
Many other methods for handling effects in Redux, especially those implementedwith action-creators, incorrectly teach the user that asynchronous effects arefundamentally different from synchronous state transitions. This separationencourages divergent and increasingly specific means of processing particulartypes effects. Instead, we should focus on making our reducers powerful enoughto handle asynchronous effects as well as synchronous state transitions. Withredux-loop, the reducer doesn't just decide what happensnow due to aparticular action, it decides what happensnext. All of the behavior of yourapplication can be traced through one place, and that behavior can be easily brokenapart and composed back together. This is one of the most powerful features of theElm architecture, and withredux-loop it is a feature of Redux as well.
npm install --save redux-loopPotential bugs, general discussion, and proposals or RFCs should be submittedas issues to this repo, we'll do our best to address them quickly. We use thislibrary as well and want it to be the best it can! For questions about using thelibrary,submit questions on StackOverflowwith theredux-loop tag.
If you're interested in adding something toredux-loop but don't want to waitfor us to incorporate the idea you can follow these steps to get your own installableversion ofredux-loop with your feature included:
- Fork the main repo here
- Add your feature or change
- Change the package
"name"in package.json to be"@<your-npm-username>/redux-loop - Commit to master and
npm publish npm install @<your-npm-username>/redux-loop
We arealways interested in new ideas, but sometimes we get a little busy and fallbehind on responding and reviewing PRs. Hopefully this process will allow you tocontinue making progress on your projects and also provide us with more context if andwhen you do decide to make a PR for your new feature or change. The best way to verifynew features for a library is to use them in real-world scenarios!
Please note that this project is released with aContributor Code of Conduct. By participating in this project you agree to abide by its terms. Multiple language translations are available atcontributor-covenant.org
About
A library that ports Elm's effect system to Redux
Resources
License
MIT, Unknown licenses found
Licenses found
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
