{"id":20579582,"url":"https://github.com/wolox/redux-recompose","last_synced_at":"2025-05-09T00:03:36.047Z","repository":{"id":26908358,"uuid":"111131115","full_name":"Wolox/redux-recompose","owner":"Wolox","description":"A Redux utility belt for reducers and actions. Inspired by acdlite/recompose.","archived":false,"fork":false,"pushed_at":"2023-08-07T21:12:28.000Z","size":1518,"stargazers_count":70,"open_issues_count":25,"forks_count":16,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-05-09T00:02:56.047Z","etag":null,"topics":["async-actions","reducer","redux","wolox"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Wolox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-17T17:20:20.000Z","updated_at":"2023-11-23T15:36:35.000Z","dependencies_parsed_at":"2024-12-26T12:07:21.630Z","dependency_job_id":"2fb89a40-5298-41cd-8a96-996976a82e93","html_url":"https://github.com/Wolox/redux-recompose","commit_stats":{"total_commits":291,"total_committers":21,"mean_commits":"13.857142857142858","dds":0.6872852233676976,"last_synced_commit":"a9f5196549f4a07ee5c4c25b25b7a738ed21e0b8"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolox%2Fredux-recompose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolox%2Fredux-recompose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolox%2Fredux-recompose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolox%2Fredux-recompose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wolox","download_url":"https://codeload.github.com/Wolox/redux-recompose/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166502,"owners_count":21864475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async-actions","reducer","redux","wolox"],"created_at":"2024-11-16T06:17:31.727Z","updated_at":"2025-05-09T00:03:35.800Z","avatar_url":"https://github.com/Wolox.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n![versión npm](https://img.shields.io/npm/v/redux-recompose.svg?color=68d5f7)\n![Download npm](https://img.shields.io/npm/dw/redux-recompose.svg?color=7551bb)\n[![codecov](https://codecov.io/gh/Wolox/redux-recompose/branch/master/graph/badge.svg)](https://codecov.io/gh/Wolox/redux-recompose)\n[![supported by](https://img.shields.io/badge/supported%20by-Wolox.💗-blue.svg)](https://www.wolox.com.ar/)\n# Redux-recompose  \n![Vertical Logo Redux-recompose](./logo/images/Redux_vertical_small@2x.png)\n\n## Why another Redux library ?\n\n`redux-recompose` provide tools to write less reducers/actions code.\n\nHere is a [blog post](https://medium.com/wolox-driving-innovation/932e746b0198) about it.\n\nUsually, we are used to write:\n\n```js\n// actions.js\n\nfunction increment(anAmount) {\n  return { type: 'INCREMENT', payload: anAmount };\n}\n\n// reducer.js\n\nfunction reducer(state = initialState, action) {\n  switch(action.type) {\n    case 'INCREMENT':\n      return { ...state, counter: state.counter + action.payload };\n    default:\n      return state;\n  }\n}\n```\n\nWith the new concept of _target_ of an action, we could write something like:\n\n```js\n// actions.js\n\n// Define an action. It will place the result on state.counter\nfunction increment(anAmount) {\n  return { type: 'INCREMENT', target: 'counter', payload: anAmount };\n}\n\n\n// reducer.js\n// Create a new effect decoupled from the state structure at all.\nconst onAdd = (state, action) =\u003e ({ ...state, [action.target]: state[action.target] + action.payload });\n\n// Describe your reducer - without the switch\nconst reducerDescription = {\n  'INCREMENT': onAdd()\n}\n\n// Create it !\nconst reducer = createReducer(initialState, reducerDescription);\n```\n\n## Effects\n\nEffects are functions that describe _how_ the state changes, but are agnostic of _what part_\nof the state is being changed.\n\n`redux-recompose` provides some effects to ease reducer definitions. These are:\n\n- [onDelete](./src/effects/onDelete/)\n- [onDeleteByIndex](./src/effects/onDeleteByIndex/)\n- [onFailure](./src/effects/onFailure/)\n- [onLoaded](./src/effects/onLoaded/)\n- [onLoading](./src/effects/onLoading/)\n- [onReadValue](./src/effects/onReadValue/)\n- [onSetValue](./src/effects/onSetValue/)\n- [onSuccess](./src/effects/onSuccess/)\n- [onAppend](./src/effects/onAppend/)\n- [onConcatenate](./src/effects/onConcatenate/)\n- [onToggle](./src/effects/onToggle/)\n- [onSpreadValue](./src/effects/onSpreadValue/)\n- [onCycle](./src/effects/onCycle/)\n- [onReplace](./src/effects/onReplace/)\n- [onRetry](./src/effects/onRetry/)\n- [onCancel](./src/effects/onCancel/)\n\nNew effects are welcome ! Feel free to open an issue or even a PR.\n\n## Creators\n\nThere are a few creators that also ease writing Redux reducers and async actions.\n\n- [createReducer](./src/creators/createReducer/)\n- [createTypes](./src/creators/createTypes/)\n- [createThunkAction](./src/creators/createThunkAction/)\n\nSince state handling is decoupled from its state, we could create some more complex async actions, or even map an effect with an action type to create families of actions.  \nMore crazy and useful ideas are welcome too!\n\n## Completers\n\nYou could use completers to reduce your code size. Completers are functions that take\npartial definitions (i.e. descriptors) and help to construct the whole definition.\n\nCompleters in general looks like this:\n\n- A pattern is being repeated in an element.\n- Identify that pattern and try to apply to every element similar to those who use this pattern, although they apply it or not.\n- Add some exceptions for elements who don't use this pattern.\n- Compress your code size by applying that pattern to all elements but not for exception cases.\n\nThere are a few completers that can be used:\n\n- [completeState](./src/completers/completeState/)\n- [completeReducer](./src/completers/completeReducer/)\n- [completeTypes](./src/completers/completeTypes/)\n\n## Injectors\n\nThere's currently documentation for the following:\n\n- [withFailure](./src/injections/withFailure/)\n- [withFlowDetermination](./src/injections/withFlowDetermination/)\n- [withPostFailure](./src/injections/withPostFailure/)\n- [withPostFetch](./src/injections/withPostFetch/)\n- [withPostSuccess](./src/injections/withPostSuccess/)\n- [withPreFetch](./src/injections/withPreFetch/)\n- [withStatusHandling](./src/injections/withStatusHandling/)\n- [withSuccess](./src/injections/withSuccess/)\n\n## Middlewares\n\nMiddlewares allow to inject logic between dispatching the action and the actual desired change in the store. Middlewares are particularly helpful when handling asynchronous actions.\n\nThe following are currently available:\n\n- [fetchMiddleware](./src/middlewares/)\n\n## Using with immutable libraries\n\nThe way `redux-recompose` updates the redux state can be configured. The default configuration is\n\n```js\n(state, newContent) =\u003e ({ ...state, ...newContent })\n```\n\nYou can use `configureMergeState` to override the way `redux-recompose` handles state merging. This is specially useful when you are using immutable libraries.\nFor example, if you are using `seamless-immutable` to keep your store immutable, you'll want to use it's [`merge`](https://github.com/rtfeldman/seamless-immutable#merge) function. You can do so with the following configuration:\n\n```js\nimport { configureMergeState } from 'redux-recompose';\n\nconfigureMergeState((state, newContent) =\u003e state.merge(newContent))\n```\n\n## Recipes\n\n- [Making HTTP requests by dispatching a redux action](./recipes/FETCHING.md)\n- [Invisible Reducer](./recipes/INVISIBLE.md)\n- [Polling](./recipes/POLLING.md)\n\n## Thanks to\n\nThis library was inspired by acdlite/recompose. Let's keep creating tools for ease development.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## About\n\nThis project was written by [Manuel Battan](https://github.com/mvbattan) and it is maintained by [Wolox](http://www.wolox.com.ar).\n\n![Wolox](https://raw.githubusercontent.com/Wolox/press-kit/master/logos/logo_banner.png)\n\n## License\n\n**redux-recompose** is available under the MIT [license](LICENSE).\n\n    Copyright (c) 2017 Manuel Battan \u003cmanuel.battan@wolox.com.ar\u003e\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in\n    all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n    THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolox%2Fredux-recompose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwolox%2Fredux-recompose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolox%2Fredux-recompose/lists"}