{"id":18939150,"url":"https://github.com/darmikon/ducks-helpers","last_synced_at":"2026-05-07T18:32:42.289Z","repository":{"id":57216952,"uuid":"79043879","full_name":"Darmikon/ducks-helpers","owner":"Darmikon","description":"Some functions which helps to reduce boilerplate in redux ducks files","archived":false,"fork":false,"pushed_at":"2017-02-09T08:49:42.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T07:02:21.356Z","etag":null,"topics":["ducks","ducks-helpers","react","react-redux","reactjs","redux","redux-actions"],"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/Darmikon.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-01-15T16:19:02.000Z","updated_at":"2023-04-27T14:57:39.000Z","dependencies_parsed_at":"2022-08-28T21:40:20.392Z","dependency_job_id":null,"html_url":"https://github.com/Darmikon/ducks-helpers","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Darmikon%2Fducks-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Darmikon%2Fducks-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Darmikon%2Fducks-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Darmikon%2Fducks-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Darmikon","download_url":"https://codeload.github.com/Darmikon/ducks-helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239937701,"owners_count":19721484,"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":["ducks","ducks-helpers","react","react-redux","reactjs","redux","redux-actions"],"created_at":"2024-11-08T12:16:32.349Z","updated_at":"2026-03-22T10:30:15.503Z","avatar_url":"https://github.com/Darmikon.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ducks-helpers\nUtils for [ducks](https://github.com/erikras/ducks-modular-redux) in redux to create action types and actions creators\n\n###Installation\n```\nnpm i --save ducks-helpers\n```\n\n###`constants(namespace, actions)`\n`constants()` - generates action types names\nIf `~` sign presents at the beginning of the string\nthen extra sufixes will be generated:\n```\n// available SUFFIXES\n\n// 'LOADING'\n// 'PENDING'\n// 'SUCCESS'\n// 'ERROR'\n// 'FAILED'\n// 'CANCELED'\n```\n\nHow to use:\n```\nimport {constants} from 'ducks-helpers'\nexport const TYPE = constants('module-name/namespace', [\n    '~ASYNC_ACTION',\n    'SYNC_ACTION'\n])\n```\n\nResult:\n```\n// with ~\n// TYPE.ASYNC_ACTION === 'module-name/namespace/ASYNC_ACTION'\n// TYPE.ASYNC_ACTION_SUCCESS === 'module-name/namespace/ASYNC_ACTION_SUCCESS'\n//...\n// TYPE.ASYNC_ACTION_CANCELED === 'module-name/namespace/ASYNC_ACTION_CANCELED'\n\n// without ~\n// TYPE.SYNC_ACTION === 'module-name/namespace/SYNC_ACTION'\n```\n\nUsing handleActions() from [redux-actions](https://github.com/acdlite/redux-actions#handleactionsreducermap-defaultstate)\n```\n// reducer\nexport default handleActions({\n    [TYPE.SYNC_ACTION]: (state, action) =\u003e state,\n    [TYPE.ASYNC_ACTION]: (state, action) =\u003e state,\n    [TYPE.ASYNC_ACTION_LOADING]: (state, action) =\u003e state,\n    //... other suffixes also are available and can be used\n    [TYPE.ASYNC_ACTION_SUCCESS]: (state, action) =\u003e state,\n    [TYPE.ASYNC_ACTION_ERROR]: (state, action) =\u003e state,\n}, {})\n```\n\n\n###`actions(types)`\n\n`types` is an array of constants.\nIn case of using `~` sign at the beginning of action name\nit will also create action creators with suffixes\n`syncAction`,\n`asyncAction`,\n`asyncActionLoading`,\n`asyncActionPending`,\n`asyncActionCanceled`,\n`asyncActionError`,\n`asyncActionFailed`\nusing redux-actions:\n```\nimport {actions} from 'ducks-helpers'\nexport const ACTION = actions(TYPE)\n```\n\nAll action creators have been built now.\nYou can use any action creators in your container.\n\n```\n// container.js\nimport { ACTION } from '../duck'\n...\n@connect(\n    ...,\n    {\n        asyncAction: ACTION.asyncAction\n    }\n\n)\n...\n\ncomponentWillMount(){\n    this.props.asyncAction()\n}\n\n...\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarmikon%2Fducks-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdarmikon%2Fducks-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdarmikon%2Fducks-helpers/lists"}