{"id":24688364,"url":"https://github.com/anvk/redux-create-actiontype","last_synced_at":"2025-10-08T17:30:16.457Z","repository":{"id":57350504,"uuid":"76697958","full_name":"anvk/redux-create-actiontype","owner":"anvk","description":"Micro library for easy Action Types generation in Redux/React.","archived":false,"fork":false,"pushed_at":"2017-10-24T02:20:12.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T11:17:48.417Z","etag":null,"topics":["actions","actiontype","creator","micro-library","react","redux"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/redux-create-actiontype","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anvk.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":"2016-12-17T01:56:00.000Z","updated_at":"2018-12-17T16:34:57.000Z","dependencies_parsed_at":"2022-09-16T21:11:27.703Z","dependency_job_id":null,"html_url":"https://github.com/anvk/redux-create-actiontype","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvk%2Fredux-create-actiontype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvk%2Fredux-create-actiontype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvk%2Fredux-create-actiontype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anvk%2Fredux-create-actiontype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anvk","download_url":"https://codeload.github.com/anvk/redux-create-actiontype/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235733804,"owners_count":19036958,"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":["actions","actiontype","creator","micro-library","react","redux"],"created_at":"2025-01-26T17:16:52.640Z","updated_at":"2025-10-08T17:30:16.150Z","avatar_url":"https://github.com/anvk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redux-create-actiontype [![Build Status](https://travis-ci.org/anvk/redux-create-actiontype.svg?branch=master)](https://travis-ci.org/anvk/redux-create-actiontype)\n\n\u003e Micro library for easy Action Types generation in Redux/React.\n\n## Install\n\n```\n$ npm install redux-create-actiontype --save\n```\n\n## Usage\n\n### Basic Usage\n\nCreate a basic object with Action Types:\n\n```js\nimport createActionTypes from 'redux-create-actiontype';\n\nconst types = createActionTypes()(\n  'login',\n  'logout',\n  'is fetching',\n  'CREATE_ACTION'\n);\n\n/* it is going to generate\nconst types = {\n  LOGIN: 'LOGIN',\n  LOGOUT: 'LOGOUT',\n  IS_FETCHING: 'IS_FETCHING',\n  CREATE_ACTION: 'CREATE_ACTION'\n};\n*/\n```\n\nAn example which is closer to a a real world project:\n\n```js\nconst types = createActionTypes('my app')(\n  'login',\n  'logout',\n  createActionTypes('users')(\n    { 'fetch': { api: true } },\n    { 'dialog': { postfixes: ['open', 'close' ]}},\n    'send email',\n    'eat borscht'\n  )\n);\n\n/* it is going to generate\nconst types = {\n  MY_APP_LOGIN: 'MY_APP_LOGIN',\n  MY_APP_LOGOUT: 'MY_APP_LOGOUT',\n  MY_APP_USERS_FETCH_LOADING: 'MY_APP_USERS_FETCH_LOADING',\n  MY_APP_USERS_FETCH_SUCCESS: 'MY_APP_USERS_FETCH_SUCCESS',\n  MY_APP_USERS_FETCH_ERROR: 'MY_APP_USERS_FETCH_ERROR',\n  MY_APP_USERS_DIALOG_OPEN: 'MY_APP_USERS_DIALOG_OPEN',\n  MY_APP_USERS_DIALOG_CLOSE: 'MY_APP_USERS_DIALOG_CLOSE',\n  MY_APP_USERS_SEND_EMAIL: 'MY_APP_USERS_SEND_EMAIL',\n  MY_APP_USERS_EAT_BORSCHT: 'MY_APP_USERS_EAT_BORSCHT'\n};\n*/\n```\n\n### Advanced Usage:\n\nGenerating API Action Types\n\n```js\nconst types = createActionTypes('my app')(\n  'login',\n  'logout',\n  { 'user': { api: true } }\n);\n\n/* it is going to generate\nconst types = {\n  MY_APP_LOGIN: 'MY_APP_LOGIN',\n  MY_APP_LOGOUT: 'MY_APP_LOGOUT',\n  MY_APP_USER_LOADING: 'MY_APP_USER_LOADING',\n  MY_APP_USER_SUCCESS: 'MY_APP_USER_SUCCESS',\n  MY_APP_USER_ERROR: 'MY_APP_USER_ERROR',\n};\n*/\n```\n\nPre-define custom API postfixes\n\n```js\nconst types = createActionTypes({\n  prefix: 'my app',\n  apiPostfixes: ['OK', 'BAD']\n})(\n  'login',\n  'logout',\n  { 'user': { api: true } },\n  { 'items': { api: true } }\n);\n\n/* it is going to generate\nconst types = {\n  MY_APP_LOGIN: 'MY_APP_LOGIN',\n  MY_APP_LOGOUT: 'MY_APP_LOGOUT',\n  MY_APP_USER_OK: 'MY_APP_USER_OK',\n  MY_APP_USER_BAD: 'MY_APP_USER_BAD',\n  MY_APP_ITEMS_OK: 'MY_APP_ITEMS_OK',\n  MY_APP_ITEMS_BAD: 'MY_APP_ITEMS_BAD'\n};\n*/\n```\n\nCustom postfixes for a custom Action Type\n\n```js\nconst types = createActionTypes('my app')(\n  'login',\n  'logout',\n  { 'dialog': { postfixes: ['open', 'close'] } }\n);\n\n/* it is going to generate\nconst types = {\n  MY_APP_LOGIN: 'MY_APP_LOGIN',\n  MY_APP_LOGOUT: 'MY_APP_LOGOUT',\n  MY_APP_DIALOG_OPEN: 'MY_APP_DIALOG_OPEN',\n  MY_APP_DIALOG_CLOSE: 'MY_APP_DIALOG_CLOSE'\n};\n*/\n\n// OR\n// the following code yields the same results\nconst types = createActionTypes('my app')(\n  'login',\n  'logout',\n  createActionTypes('dialog')(\n    'open',\n    'close'\n  )\n);\n```\n\n(support for another style) Set a lower-case prefix with / as a separator\n\n```js\nconst types = createActionTypes({\n  prefix: 'my app',\n  prefixUpperCase: false,\n  separator: '/'\n})(\n  'login',\n  'logout'\n);\n\n/* it is going to generate\nconst types = {\n  'my_app/LOGIN': 'my_app/LOGIN',\n  'my_app/LOGOUT': 'my_app/LOGOUT'\n};\n*/\n```\n\ndeep structured actions\n\n```js\nconst types = createActionTypes('my app')(\n  'login',\n  'logout',\n  createActionTypes('dialog')(\n    'open',\n    'close',\n    createActionTypes('input')(\n      'change',\n      'on focus'\n    )\n  )\n);\n\n/* it is going to generate\nconst types = {\n  MY_APP_LOGIN: 'MY_APP_LOGIN',\n  MY_APP_LOGOUT: 'MY_APP_LOGOUT',\n  MY_APP_DIALOG_OPEN: 'MY_APP_DIALOG_OPEN',\n  MY_APP_DIALOG_CLOSE: 'MY_APP_DIALOG_CLOSE',\n  MY_APP_DIALOG_INPUT_CHANGE: 'MY_APP_DIALOG_INPUT_CHANGE',\n  MY_APP_DIALOG_INPUT_ON_FOCUS: 'MY_APP_DIALOG_INPUT_ON_FOCUS'\n};\n*/\n```\n\n#### Options\n\n```js\nconst types = createActionTypes({\n  prefix,     // string prefix for all elements in array of types. default is ''\n  separator,  // string character which is separates prefix and each element type. default is '_'\n  upperCase,  // bool. it will set to upper case each key if set to true. default is true\n  prefixUpperCase // bool. it will set to upper case the prefix if set to true. default is true\n})(arrayOfTypes);\n```\n\n#### Default API Postfixes\n\n```js\nconst defaultAPIPostfixes = [\n  'LOADING',\n  'ERROR',\n  'SUCCESS'\n];\n```\n\n## Full list of examples\nYou can find more examples in my [test file.](./test/redux-create-actiontype-test.js)\n\n## Feedback\nFor any ideas, suggestion or bugs feel free to ping me or create a ticket [right here.](https://github.com/anvk/redux-create-actiontype/issues)\n\n## License\n\nMIT license; see [LICENSE](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanvk%2Fredux-create-actiontype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanvk%2Fredux-create-actiontype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanvk%2Fredux-create-actiontype/lists"}