{"id":18412706,"url":"https://github.com/platzidev/redux-duck","last_synced_at":"2025-10-20T10:02:53.649Z","repository":{"id":135039791,"uuid":"56629084","full_name":"PlatziDev/redux-duck","owner":"PlatziDev","description":"Helper function to create Redux modules using the ducks-modular-redux proposal","archived":false,"fork":false,"pushed_at":"2019-09-12T10:48:07.000Z","size":11,"stargazers_count":90,"open_issues_count":3,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-22T17:11:29.428Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/PlatziDev.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-19T20:20:39.000Z","updated_at":"2024-02-13T15:39:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"554575f2-9b68-48ef-b83e-bb0682728727","html_url":"https://github.com/PlatziDev/redux-duck","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/PlatziDev%2Fredux-duck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlatziDev%2Fredux-duck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlatziDev%2Fredux-duck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlatziDev%2Fredux-duck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PlatziDev","download_url":"https://codeload.github.com/PlatziDev/redux-duck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247644537,"owners_count":20972308,"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-06T03:43:11.886Z","updated_at":"2025-10-20T10:02:53.434Z","avatar_url":"https://github.com/PlatziDev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# redux-duck\nHelper function to create Redux modules using the [ducks-modular-redux](https://github.com/erikras/ducks-modular-redux/) proposal.\n\n## Installation\n```bash\nnpm i -S redux-duck\n```\n\n## API\n### Create duck\n```javascript\nimport { createDuck } from 'redux-duck';\n\nconst myDuck = createDuck('duck-name', 'application-name');\n```\n* `createDuck` receive 2 arguments, the second argument is optional.\n* The first argument is the duck name.\n* The second, and optional, argument is the application or module name.\n\n### Define action types\n```javascript\nconst ACTION_TYPE = myDuck.defineType('ACTION_TYPE');\n```\n* `defineType` receive just one argument.\n* The argument is the name of the action.\n* The result should be an string like `application-name/duck-name/ACTION_TYPE` or `duck-name/ACTION_TYPE` if the application or module name was not defined.\n\n### Create action creators\n```javascript\nconst actionType = myDuck.createAction(ACTION_TYPE);\n```\n* `createAction` receive just one argument.\n* This argument should be the defined action type string.\n* It should return a function who will receive the action payload and return a valid (FSA compilant) action object.\n* The action creator will receive an optional argument with the action payload.\n\n### Create reducer\n```javascript\nconst initialState = {\n  list: Immutable.List(),\n  data: Immutable.Map(),\n};\n\nconst reducer = myDuck.createReducer({\n  [ACTION_TYPE]: (state, action) =\u003e ({\n    ...state,\n    list: state.list.push(action.payload.id),\n    data: state.map.set(action.payload.id+'', action.payload),\n  }),\n}, initialState);\n```\n* `createReducer` receive two arguments, both required.\n* The first argument is an object with the possible action cases.\n* The second argument is the reducer initial state.\n* The first argument should use the previously defined *action types* as keys.\n* Each key in the first argument object should be a function who will receive the current state and the dispatched action as arguments and return the updated state.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatzidev%2Fredux-duck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplatzidev%2Fredux-duck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatzidev%2Fredux-duck/lists"}