{"id":15916975,"url":"https://github.com/ruben-arushanyan/actions-creator","last_synced_at":"2025-03-24T07:31:45.961Z","repository":{"id":43262759,"uuid":"356603832","full_name":"Ruben-Arushanyan/actions-creator","owner":"Ruben-Arushanyan","description":"actions-creator is an awesome javascript package that allows you to dynamically create action objects in Redux without having to declare constants and separate action-creator functions for each action.","archived":false,"fork":false,"pushed_at":"2023-01-03T08:03:37.000Z","size":1373,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-01T19:41:48.826Z","etag":null,"topics":["actions","actions-creator","create-action","javascript","produce-by-path","redux","redux-action","redux-action-callback","redux-cool"],"latest_commit_sha":null,"homepage":"https://actions-creator.js.org","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/Ruben-Arushanyan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"Ruben-Arushanyan","custom":["https://www.paypal.me/rubenarushanyan"]}},"created_at":"2021-04-10T14:21:02.000Z","updated_at":"2023-03-01T10:53:24.000Z","dependencies_parsed_at":"2023-02-01T05:31:11.800Z","dependency_job_id":null,"html_url":"https://github.com/Ruben-Arushanyan/actions-creator","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ruben-Arushanyan%2Factions-creator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ruben-Arushanyan%2Factions-creator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ruben-Arushanyan%2Factions-creator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ruben-Arushanyan%2Factions-creator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ruben-Arushanyan","download_url":"https://codeload.github.com/Ruben-Arushanyan/actions-creator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245227438,"owners_count":20580884,"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","actions-creator","create-action","javascript","produce-by-path","redux","redux-action","redux-action-callback","redux-cool"],"created_at":"2024-10-06T18:07:47.012Z","updated_at":"2025-03-24T07:31:45.648Z","avatar_url":"https://github.com/Ruben-Arushanyan.png","language":"JavaScript","funding_links":["https://github.com/sponsors/Ruben-Arushanyan","https://www.paypal.me/rubenarushanyan"],"categories":[],"sub_categories":[],"readme":"# [Actions Creator - Redux](https://actions-creator.js.org)\n\n\u003e You can find the full documentation on the [website](https://actions-creator.js.org)\n\n## Description\n\n**actions-creator** is an awesome javascript package that allows you to **dynamically** create action objects in Redux **without** declaring *CONSTANTS* and separate *action-creator* functions for each action.\n\n## [Documentation](https://actions-creator.js.org)\n- [Actions Creator](https://actions-creator.js.org/docs/actions-creator)\n- [Customization](https://actions-creator.js.org/docs/customization)\n\n## Installation\n\n```bash\nnpm install actions-creator\n```\n\n## Usage Example\n\n\n```javascript\nimport {actionsCreator} from 'actions-creator'\n\nconst action_1 = actionsCreator.MY.FIRST.ACTION('arg1')\n//      {\n//          type: 'MY/FIRST/ACTION',\n//          payload: 'arg1',\n//      } \n\nconst action_2 = actionsCreator.This.is.my.second.action(2021)\n//      {\n//          type: 'This/is/my/second/action',\n//          payload: 2021,\n//      } \n\n\n// To get the type of action\nString( actionsCreator.MY.FIRST.ACTION ) // 'MY/FIRST/ACTION'\n// or\nactionsCreator.MY.FIRST.ACTION().type // 'MY/FIRST/ACTION'\n\n```\n\n## Actions With Callback\n\nSometimes we need the action to have **callback capability**. It might be necessary in many cases.\n\n**`Actions Creator`** allows us to do this in a beautiful way: \nWhen we try to generate an action object, we can pass the **callback function** as the last argument. `Actions Creator` will check and if the last argument is a function, it will be considered as a **callback function**.\n\n```javascript\nimport {actionsCreator} from 'actions-creator'\n\nconst callback = () =\u003e {\n    console.log('Hello, I am callback!!!')\n}\n\nconst action = actionsCreator.MY.CALLBACKABLE.ACTION(123, callback)\n//      {\n//          type: 'MY/CALLBACKABLE/ACTION',\n//          payload: 123,\n//          cb: [Function callback],\n//      }\n\naction.cb() // 'Hello, I am callback!!!'\n```\n\n## Syntax\n\n### `actionsCreator.ANY.ACTION(payload, callback?)`\n\n- **payload** `\u003cAny\u003e`  \n    Any value as a payload.\n- **callback** `\u003cFunction\u003e`  \n    Any function as a callback.\n\n**Returns** `\u003cObject\u003e` \n\n- **type** `\u003cString\u003e` Action type as a string.  \n    ```js\n    actionsCreator.ANY.ACTION().type === 'ANY/ACTION' // true\n    ```\n- **payload** `\u003cAny\u003e`  \n    The value of the payload - given in the first argument.\n    ```js\n    actionsCreator.ANY.ACTION(123).payload === 123 // true\n    ```\n- **cb** `\u003cFunction\u003e`  \n    The function of the callback - given in the last argument.\n    ```js\n    const callback = () =\u003e {};\n\n    actionsCreator.ANY.ACTION(123, callback).cb === callback // true\n    ```\n\n## Customize\nWe do not recommend to customize,\nbut if you need to do it, you can easily do that: \\\nsee: [Produce By Path Pattern](https://github.com/ruben-arushanyan/produce-by-path)\n\n\n\n## [Contributing](https://github.com/ruben-arushanyan/actions-creator/blob/master/CONTRIBUTING.md)\n\nRead our [contributing guide](https://github.com/ruben-arushanyan/actions-creator/blob/master/CONTRIBUTING.md) to learn about our development process.\n\n## [Code of Conduct](https://github.com/ruben-arushanyan/actions-creator/blob/master/CODE_OF_CONDUCT.md)\n\nThis project has adopted the [Contributor Covenant](https://www.contributor-covenant.org) as its Code of Conduct, and we expect project participants to adhere to it. Please read the [full text](https://github.com/ruben-arushanyan/actions-creator/blob/master/CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.\n\n## Authors\n\n- [Ruben Arushanyan](https://github.com/ruben-arushanyan)\n\n## License\n\n[MIT License](https://github.com/ruben-arushanyan/actions-creator/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruben-arushanyan%2Factions-creator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruben-arushanyan%2Factions-creator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruben-arushanyan%2Factions-creator/lists"}