{"id":24755551,"url":"https://github.com/zefirka/reduxto","last_synced_at":"2026-04-14T18:32:31.179Z","repository":{"id":34244160,"uuid":"173315271","full_name":"zefirka/reduxto","owner":"zefirka","description":"Reducer creator for redux","archived":false,"fork":false,"pushed_at":"2023-01-03T17:11:55.000Z","size":471,"stargazers_count":1,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-25T09:04:47.402Z","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/zefirka.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":"2019-03-01T14:26:27.000Z","updated_at":"2020-03-25T11:17:39.000Z","dependencies_parsed_at":"2023-01-15T05:36:34.650Z","dependency_job_id":null,"html_url":"https://github.com/zefirka/reduxto","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zefirka/reduxto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefirka%2Freduxto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefirka%2Freduxto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefirka%2Freduxto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefirka%2Freduxto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zefirka","download_url":"https://codeload.github.com/zefirka/reduxto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zefirka%2Freduxto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31810737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-01-28T12:48:00.953Z","updated_at":"2026-04-14T18:32:31.163Z","avatar_url":"https://github.com/zefirka.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reduxto [![Build Status](https://travis-ci.org/zefirka/reduxto.svg?branch=master)](https://travis-ci.org/zefirka/reduxto)\n\n\u003cimg src=\"./static/reducto.gif\" align=\"right\" width=\"180\"/\u003e\n\nreduxto is small and simple reducer creator for redux. If you're tired to write same code for every reducer, describe actions, constants, action-handlers then you may find reduxto useful. It's totally hackable and extensible, so if your approach to action naming, data types and structures in store, namespacing your actions is different then reduxto provides by standard, you can configure reduxto for yourself very easy. \n\n## Usage and ratio\n[Look for examples, methods, configuring and extending in docs](#documentation)\n\nSimplify your reducers creation with reduxto, use it and get ready reducer and actions. No constants, no manual action creation, no copy-paste logic in reducers.\n\n```js \n// store/boxes.js\nexport {actions, reducer} = reduxto('boxes', {;\n    0: {name: 'Default Box'}\n});\n\n// store/items.js\nexport {actions, reducer} = reduxto('items', {});\n\n// store/reducer.js\nimport {reducer as boxes} from './boxes';\nimport {reducer as items} from './items';\n\nexport default combineReducers({\n    boxes,\n    items,\n});\n```\n\nreduxtor will return object `{actions, reducer}`, where will be namespaced actions `get`, `getById`, `set`, `put`, `update`, `remove`, prefixed with reducer namespace, and ready action handlers for all non-get methods in reducer.\n\n## Use it in sagas or in thunk\n```js\n// saga.js\nimport {actions} from './store/items';\n\nfunction * watchGetItems() { \n    while (true) {\n        yield take(actions.get) // take all actions with {type: 'items/getItems'}\n\n        const items = yield call(getItemsFromApi);\n        yield put(actions.set(items)) // emits action with {type: 'items/setItems', payload: items}\n    }\n}\n```\n\n## Use it in container\n\n```js\n// container.js\n\nimport {actions as boxesActions} from 'store/boxes'\nimport {actions as itemsActions} from 'store/items'\nimport Component from 'components/Component'\n\nexport connect(mapDispatchToProps, {\n    getBoxes: boxesActions.get,\n    getItems: itemsActions.get\n})\n```\n\n### Ratio\n\nWe belive that store must represent a kind of database on the client side. And it's good to divide roles in your application, when **reducers** are made for storing and manipulating data, **sagas/thunks** for handling asynchronous transactions and scenarios to manage application's behavior and **selectors** for prepare data for containers. In this approach store becomes more simplified and looks as DB: \n\n```\n{\n    ui: {\n        // data for UI\n    }\n    data: {\n        boxes: {\n            [id]: {...}\n        },\n        items: {\n            [id]: {...}\n        }\n    }\n}\n```\n\nMostly it's visible in projects with specified apis (JSONAPI, strict REST with resources). May be your storing model can be different, but anyway you will try to simplify and normalize your store.\n\nIn this case appears a neccessary for a lot of similiar actions over store. It's mostly about CRUD operations.\n\nSo we've decided that we can optimize reducer creation with reduxto.  \n\n\n## Documentation\n\u003ca href=\"docs\"\u003e\u003c/a\u003e\n\n### Reducer methods\n\nBy standard reduxto is made for work with flat objects in store, with ID as key property (normalized JSON API data) for example:\n\n```\n{\n    boxes: {\n        0: {\n            boxName: 'first',\n        },\n        1: {\n            boxName: 'second,\n        }\n    },\n    items: {\n        12: {\n            itemName: 'content'\n        }\n    }\n}\n```\n\nThis sttructure will be ok. And reduxto will provide actions\n\n#### Actions\n\nActions without handlers in reducers just for yousage in sagas/thunks\n - `get` \n - `getById` (id as payload)\n\nActions with handlers:\n - `set` - fully replace state with new one (which in payload)\n - `put` - put with merge\n - `update` - updates element in state with `payload = {id: \u003celement id\u003e, value: \u003celement value\u003e}` (merge ig element exists) \n - `remove` - remove element by id (id as payload)\n\n```js\nconst defaultState = {}\nconst {actions, reducer} = reduxto('boxes', defaultState)\n\nactions.get() // {type: 'boxes/getBoxes'}\nactions.getById(12) // {type: 'boxes/getBoxesById', payload: 12}\n\nactions.set({0: {name: 'BoxName', content: 'Box content'}}) // will fully replace state\n\n/**\n * State now: \n * {0: {name: 'BoxName', conten: 'Box content'}}\n */\nactions.put({1: {name: 'BoxName', content: 'Box content'}, 0: {content: 'changed'}}) // will put to store new object (and merge if id's matching\n\n/**\n * State now:\n * {0: {name: 'BoxName', conten: 'changed'}, 1: {name: 'BoxName', content: 'Box content'}}\n */\n\nactions.update({id: 1, value: {name: 'changed too'}) // will update with value as a diff\n\n/**\n * State now:\n * {0: {name: 'changed too', conten: 'changed'}, 1: {name: 'BoxName', content: 'Box content'}}\n */\n\nactions.remove(1) //removes element with id 1\n\n/**\n * State now:\n * {0: {name: 'changed too', conten: 'changed'}}\n */\n```\n\n## Extending and configuring\n\nYou can configure:\n - default action handlers which will be created by `reduxto`. \n - action creator (by default it use something like [`redux-namespaced-actions`](http://npmjs.com/package/redux-namespaced-actions))\n - reducer creator\n\nLet assume you want to create REST-like reducer with uppercase namespaced actions:\n\n```js\nredux.configure({\n    actions: {\n        get: null, // no action handler in reducer\n        post: (state, action) =\u003e {...},\n        put: (state, action) =\u003e {...},\n        patch: (state, action) =\u003e {...},\n        delete: (state, action) =\u003e {...}\n    },\n    actionCreator: (namespace) =\u003e (actionName) =\u003e (payload) =\u003e ({\n        type: namespace + '_' + toSnakeCase(actionName).toUpperCase(),\n        payload,\n    }),\n});\n```\n\nSo when you call to `reduxto('posts')`, you will get next actions: \n\n```js\nconst {actions, reducer} = reduxto('posts', {})\n\nactions.get(666) \n/**\n * {\n *      type: POSTS_GET,\n *      payload: 666\n * }\n */\n\nactions.post({id: 667, value: 'post'})\n/**\n * {\n *      type: POSTS_POST,\n *      payload: {id: 667, value: 'post'}\n * }\n */\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzefirka%2Freduxto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzefirka%2Freduxto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzefirka%2Freduxto/lists"}