{"id":18347976,"url":"https://github.com/collaborne/redux-byid","last_synced_at":"2025-04-06T09:31:36.720Z","repository":{"id":57350361,"uuid":"155216153","full_name":"Collaborne/redux-byid","owner":"Collaborne","description":"Redux helper to define a \"by-id\" mapping of reducers","archived":false,"fork":false,"pushed_at":"2020-06-10T20:39:25.000Z","size":60,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T13:29:41.296Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Collaborne.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-29T13:25:36.000Z","updated_at":"2023-05-05T20:20:16.000Z","dependencies_parsed_at":"2022-09-16T21:00:57.419Z","dependency_job_id":null,"html_url":"https://github.com/Collaborne/redux-byid","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Collaborne%2Fredux-byid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Collaborne%2Fredux-byid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Collaborne%2Fredux-byid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Collaborne%2Fredux-byid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Collaborne","download_url":"https://codeload.github.com/Collaborne/redux-byid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247463744,"owners_count":20942935,"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-05T21:15:53.589Z","updated_at":"2025-04-06T09:31:36.450Z","avatar_url":"https://github.com/Collaborne.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redux-byid [![Build Status](https://travis-ci.org/Collaborne/redux-byid.svg?branch=master)](https://travis-ci.org/Collaborne/redux-byid)\n\nA helper for redux that allows to distribute an action to one specific part of a map of similar \"things\".\n\nThis [blog post](https://medium.com/collaborne-engineering/redux-pattern-byid-reducers-323a863fa64e?source=friends_link\u0026sk=e48bad30e5d950abf98f366c001f03aa) details the background of this library.\n\n## Usage\n\n```sh\nnpm install --save redux-byid\n```\n\nYou can then define a \"by-id\" state:\n```js\nconst { byId } = require('redux-byid');\n\n/**\n * Reducer for a single item\n */\nfunction itemReducer(state, action) {\n    switch (action.type) {\n        case 'item/added':\n            return {id: action.item_id, data: action.data};\n        case 'item/updated':\n            return {id: action.item_id, data: action.updated};\n        case 'item/deleted':\n            // Item is deleted, return undefined. byId will drop out the state.\n            return undefined;\n        default:\n            return state;\n    }\n}\n\n/**\n * Actual reducer, produces a map of item id -\u003e item reducer.\n */\nconst reducer = byId(action =\u003e action.item_id, itemReducer);\n```\n\n## License\n\n    This software is licensed under the Apache 2 license, quoted below.\n\n    Copyright 2011-2019 Collaborne B.V. \u003chttp://github.com/Collaborne/\u003e\n\n    Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n    use this file except in compliance with the License. You may obtain a copy of\n    the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n    License for the specific language governing permissions and limitations under\n    the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcollaborne%2Fredux-byid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcollaborne%2Fredux-byid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcollaborne%2Fredux-byid/lists"}