{"id":15823274,"url":"https://github.com/varharrie/vuex-action","last_synced_at":"2025-05-12T13:24:01.215Z","repository":{"id":96983346,"uuid":"74796772","full_name":"varHarrie/vuex-action","owner":"varHarrie","description":":hammer: Utilities for vuex to easily create and manage actions.","archived":false,"fork":false,"pushed_at":"2017-03-14T03:52:40.000Z","size":24,"stargazers_count":26,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-26T19:48:37.685Z","etag":null,"topics":["vuejs","vuejs2","vuex","vuex-action"],"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/varHarrie.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}},"created_at":"2016-11-26T01:05:23.000Z","updated_at":"2023-08-28T05:18:02.000Z","dependencies_parsed_at":"2023-07-21T17:51:24.876Z","dependency_job_id":null,"html_url":"https://github.com/varHarrie/vuex-action","commit_stats":{"total_commits":34,"total_committers":1,"mean_commits":34.0,"dds":0.0,"last_synced_commit":"e123733c13d3036eac475a07aca5e746fd9bf452"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varHarrie%2Fvuex-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varHarrie%2Fvuex-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varHarrie%2Fvuex-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varHarrie%2Fvuex-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/varHarrie","download_url":"https://codeload.github.com/varHarrie/vuex-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253745629,"owners_count":21957415,"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":["vuejs","vuejs2","vuex","vuex-action"],"created_at":"2024-10-05T08:07:28.336Z","updated_at":"2025-05-12T13:24:01.191Z","avatar_url":"https://github.com/varHarrie.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vuex-action\n\nUtilities for vuex to easily create and manage actions.\n\n- Allow you to create `untyped` action\n- Support for `Promise`\n- Work with `vue@1` and `vue@2`\n\n## Installation\n\n```bash\n  npm install --save vuex-action\n```\n\n## API\n\n```javascript\n  import {createAction, createActions} from 'vuex-action'\n```\n\n### createAction(type?: string, payloadHandler?: () =\u003e any | Promise)\n\nIt creates an `action`, and the action `type` will generated by uuidV4() if not specified.\n\n### createActions(prefix?: string, payloadHandlers: Array | Object)\n\nSimilarly, creates a lot of actions.\n\n## Usage\n\n\u003e For complete examples, see [examples](https://github.com/varHarrie/vuex-action/tree/master/examples)\n\n```javascript\n  // Create an action\n  const increment = createAction('ACTION_TYPE')\n  // Or\n  const increment = createAction()\n```\n\nWith normal function:\n```javascript\n  // PayloadHandler allows you to customize the payload\n  const add = createAction((num) =\u003e num || 1)\n  // Therefore\n  store.dispatch('add') // + 1\n  store.dispatch('add', 5) // + 5\n```\n\nWith Promise:\n```javascript\n  // Here is a function to fetch a user\n  const fetchUserApi = function (name) {\n    return Promise.resolve({username: name})\n  }\n  // Return a Promise\n  const fetchUser = createAction((name) =\u003e fetchUserApi(name))\n  store.dispatch('fetchUser', 'Harrie') // payload = {username: 'Harrie'}\n```\n\nOr create actions together:\n\n```javascript\n// use `createActions` instance of `createAction`\nconst actions = createActions([\n  'increment',\n  {\n    add: (num) =\u003e num || 1,\n    fetchUser: (name) =\u003e fetchUserApi(name)\n  }\n])\n```\n\nThe store:\n\n```javascript\n  const store = new Vuex.Store({\n    state: {\n      count: 0,\n      user: null\n    },\n    mutations: {\n      // Just make it as a type\n      [increment] (state, num) {\n        state.count += num\n      },\n      [fetchUser] (state, user) {\n        state.user = user\n      }\n    },\n    actions: {\n      increment,\n      fetchUser\n    }\n  })\n```\n\n## Inspired by\n\n* [redux-act](https://github.com/pauldijou/redux-act) by [pauldijou](https://github.com/pauldijou)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarharrie%2Fvuex-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvarharrie%2Fvuex-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarharrie%2Fvuex-action/lists"}