{"id":52140492,"url":"https://github.com/gettintoasty/redux-creator","last_synced_at":"2026-08-06T07:01:10.403Z","repository":{"id":57350466,"uuid":"103540192","full_name":"gettinToasty/redux-creator","owner":"gettinToasty","description":"A lightweight library to reduce Redux boilerplate","archived":false,"fork":false,"pushed_at":"2018-06-06T11:19:39.000Z","size":53,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-24T02:16:52.920Z","etag":null,"topics":["actions","boilerplate","functions","generator","generators","helper","helpers","methods","middleware","react","reducer","redux","store","thunks"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/redux-creator","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/gettinToasty.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-09-14T14:08:39.000Z","updated_at":"2024-09-04T06:14:18.000Z","dependencies_parsed_at":"2022-09-17T01:23:47.488Z","dependency_job_id":null,"html_url":"https://github.com/gettinToasty/redux-creator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gettinToasty/redux-creator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettinToasty%2Fredux-creator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettinToasty%2Fredux-creator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettinToasty%2Fredux-creator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettinToasty%2Fredux-creator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gettinToasty","download_url":"https://codeload.github.com/gettinToasty/redux-creator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettinToasty%2Fredux-creator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":36329732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-08-06T04:43:03.162Z","status":"ssl_error","status_checked_at":"2026-08-06T04:43:02.660Z","response_time":54,"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":["actions","boilerplate","functions","generator","generators","helper","helpers","methods","middleware","react","reducer","redux","store","thunks"],"created_at":"2026-08-06T07:00:33.124Z","updated_at":"2026-08-06T07:01:10.267Z","avatar_url":"https://github.com/gettinToasty.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# New in 0.2.0\n* `createThunk` now supports a `deserializer` function to parse response data\n* `createThunk` and `createReducer` now require strong parameters\n* `$apply` now properly applies to the current state value instead of the payload while using `createReducer`\n\n# Redux Creator\n\nThis is a lightweight library designed to help reduce the amount of boilerplate usually required in Redux workflows. There are several easy to use functions that can help reduce the size of your redux/ducks files by dozens of lines!\n\n# Installation\n\nRedux Creator is incredibly easy to install, simply run one of these lines in your terminal:\n\nNPM: `npm install redux-creator --save`\n\nYarn: `yarn add redux-creator`\n\n# Usage\n\n## `createAction`\n\nThis is a fairly straightforward function that takes an action type as a method and returns a redux function. The only opinion it holds is that the data passed into the action body is referred to as payload.\n\n### Example\n```js\nconst UPDATE_MESSAGE = 'messages/UPDATE_MESSAGE';\n\nexport const updateMessage = createAction(UPDATE_MESSAGE); \n/*=\u003e (payload) =\u003e ({\n  type: 'messages/UPDATE_MESSAGE',\n  payload\n}) */\n```\n\n## `createThunk`\n\nAnother easy to use function when making API calls in your redux cycle. This function takes an API util function and an action as arguments, and returns the default 'thunk' pattern of asynchronous actions. Thunks return promisable objects by default, and this helper is no different.\n\n### Example\n```js\nexport const sendMessage = createThunk({\n  api: MessageAPI.send,\n  action: updateMessage,\n});\n/* =\u003e (data) =\u003e (dispatch) =\u003e {\n  MessageAPI.send(data)\n    .then((resp) =\u003e (\n      dispatch(updateMessage(resp));\n      return resp;\n    })\n) */\n```\n\n`createThunk` can also be used to handle errors, with an `errorHandler` function:\n\n```js\nexport const sendMessage = createThunk({\n  api: MessageAPI.send,\n  action: updateMessage,\n  errorHandler: updateMessageErrors\n});\n/* =\u003e (data) =\u003e (dispatch) =\u003e (\n  MessageAPI.send(data)\n    .then((resp) =\u003e {\n      dispatch(updateMessage(resp));\n      return resp;\n    })\n    .catch((err) =\u003e {\n      dispatch(updateMessageErrors(err));\n      return err;\n    })\n) */\n```\n\nAn optional `deserializer` layer can also be applied to `createThunk` if you are expecting to recieve API data that requires parsing. Deserializers should be provided as functions:\n\n```js\nexport const sendMessage = createThunk({\n  api: MessageAPI.send,\n  action: updateMessage,\n  deserializer: parseMessageResponse\n});\n/* =\u003e (data) =\u003e (dispatch) =\u003e (\n  MessageAPI.send(data)\n    .then((resp) =\u003e parseMessageResponse(resp))\n    .then((resp) =\u003e {\n      dispatch(updateMessage(resp));\n      return resp;\n    })\n) */\n```\n\n## `configureStore`\n\nThis is a helper method which takes in the root reducer in your redux and an array of middleware and creates a store with those middlewares applied.\n\n### Example\n```js\nexport default configureStore(RootReducer, [thunk])\n// =\u003e (preloadedState = {}) =\u003e createStore(RootReducer, preloadedState, applyMiddleware(thunk))\n```\n\n## `createReducer`\n\nThis is the most complicated of the helper functions but also has the biggest payoff. Reducers are often bulky and hard to read, and `createReducer` aims to create a prettier looking reducer that's much easier to grok. This is the most opinionated of the helper methods, and a somewhat specific syntax must be followed in order for it to properly work.\n\n### Example\n```js\nconst UPDATE_MESSAGE = 'messages/UPDATE_MESSAGE';\nconst UPDATE_MESSAGE_ERRORS = 'messages/UPDATE_MESSAGE_ERRORS';\n\nconst messageReducerActions = {\n  [UPDATE_MESSAGE]: '{ \"currentUser\": { \"message\": { \"$set\": $payload } } }',\n  [UPDATE_MESSAGE_ERRORS]: '{ \"currentUser\": { \"errors\": { \"message\": { \"$set\": $payload } } } }'\n}\n\nexport default createReducer({\n  reducerCases: messageReducerActions,\n  initialState\n});\n/* =\u003e (state = initialState, action) =\u003e {\n  let reducerObj = {\n    'messages/UPDATE_MESSAGE': (payload) =\u003e update(state, { currentUser: { message: { $set: payload } }),\n    'messages/UPDATE_MESSAGE_ERRORS': (payload) =\u003e update(state, { currentUser: { errors: { message: { $set: payload } } } })\n  };\n  return reducerObj[action.type](action.payload) || state;\n}\n*/\n```\n\nThe pattern is as follows: `createReducer` accepts an Object of action types as keys and JSON strings as values. The JSON strings use the same syntax as the `update` method from the `immutability-helper` library, which is used internally as shown, but the strings must be valid JSON to work. After calling for an `update` operation like `$set` or `$merge`, the value of that key must be marked as `$payload`. Because the value is just a string it won't throw any invalid JSON syntax errors until it is parsed by `createReducer`, at which time `$payload` will be substituted with the proper value. This is also the reason `createAction` uses the naming convention of `$payload` on its action data; `createReducer` relies on `action.payload` to function properly.\n\n### Handling Apply\n\nIf you wish to use `immutability-helper`'s built-in `$apply` method it is important to note the format of the reducer case. Instead of the typical JSON string, `createReducer` expects an object with the keys `string`, for the JSON string including `$callback` instead of `$payload`, and `callback`, which is the actual callback function.\n\n## MIT License\n\nCopyright (c) 2017 Sean Beyer\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgettintoasty%2Fredux-creator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgettintoasty%2Fredux-creator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgettintoasty%2Fredux-creator/lists"}