{"id":18799547,"url":"https://github.com/l2silver/redux-overlord","last_synced_at":"2026-01-02T20:30:16.762Z","repository":{"id":57351167,"uuid":"84157112","full_name":"l2silver/redux-overlord","owner":"l2silver","description":null,"archived":false,"fork":false,"pushed_at":"2017-03-07T05:10:27.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-11T14:41:29.644Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/l2silver.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-07T05:06:34.000Z","updated_at":"2017-12-10T15:25:40.000Z","dependencies_parsed_at":"2022-09-16T21:11:48.830Z","dependency_job_id":null,"html_url":"https://github.com/l2silver/redux-overlord","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Fredux-overlord","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Fredux-overlord/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Fredux-overlord/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/l2silver%2Fredux-overlord/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/l2silver","download_url":"https://codeload.github.com/l2silver/redux-overlord/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239727746,"owners_count":19687241,"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":[],"created_at":"2024-11-07T22:15:42.236Z","updated_at":"2026-01-02T20:30:16.705Z","avatar_url":"https://github.com/l2silver.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"redux-overlord\n=====================\n\nGive an overlord reducer access to the entire combineReducer state\n\n[![Build Status](https://travis-ci.org/l2silver/redux-overlord.svg?branch=master)](https://travis-ci.org/l2silver/redux-overlord)\n\n\n## Why\nAlthough sharing the state of reducers is generally considered an anti pattern, there are cases where it's neeccessary. For myself, I wanted the ability to batch complex actions together, and one of those actions was a generic reordering action. I separate my relationship reducers from their respective entities to take advantage of handling a single action with multiple reducers, but the problem with the reordering action is that it relies on information in the entities themselves. Now under normal circumstances, I would get the state, get all the information I need, and then send the reorder action with the correct order already calculated. Since I'm batching actions, however, and my reorder action depends on the preceding actions, I need the ability to calculate and change the reordered relationship directly inside an overlord reducer.\n\n```\nnpm install --save redux-overlord\n```\n\n## Usage\n\n```\nimport {createStore, combineReducers} from 'redux';\nimport shadowReducer from 'redux-overlord';\n\nfunction one(state, action){\n\tswitch(action.type){\n\t\tdefault:\n\t\t\treturn 1\n\t}\n}\n\nfunction two(state, action){\n\tswitch(action.type){\n\t\tdefault:\n\t\t\treturn 2\n\t}\n}\n\nconst overlordReducer = function(state, action){\n\tswitch(action.type)\n\t\tdefault:\n\t\t\treturn {one: state.one, two: state.two + 1}\n}\n\nconst shadowedReducer = shadowReducer(\n\tcombineReducers({one, two}),\n\toverlordReducer\n)\n\n\n\nconst store = createStore(shadowedReducer, initialState)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl2silver%2Fredux-overlord","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fl2silver%2Fredux-overlord","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fl2silver%2Fredux-overlord/lists"}