# vuex-action-patcher

> Vuex - Add tools to the Action context

Latest version **1.0.0** (published 2019-02-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install vuex-action-patcher
pnpm add vuex-action-patcher
yarn add vuex-action-patcher
bun add vuex-action-patcher
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-02-23 |
| First published | 2019-02-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Alan J. Fitzpatrick |
| Maintainers | staratarms |
| Keywords | vue, vuex, vuex-plugin |

## Links

- npm: https://www.npmjs.com/package/vuex-action-patcher
- Repository: https://github.com/alajfit/vuex-action-patcher
- Homepage: https://github.com/alajfit/vuex-action-patcher#readme
- Issues: https://github.com/alajfit/vuex-action-patcher/issues
- npm.io page: https://npm.io/package/vuex-action-patcher

## Recent versions

- 1.0.0 (latest) — 2019-02-23
- 0.3.0 — 2019-02-23
- 0.2.0 — 2019-02-23
- 0.1.0 — 2019-02-23
- 0.0.1 — 2019-02-23

## README

# Vuex Action Patcher (Adding Tools to Your Context)
[![Build Status](https://travis-ci.org/alajfit/vuex-action-patcher.svg?branch=master)](https://travis-ci.org/alajfit/vuex-action-patcher)
[![codecov](https://codecov.io/gh/alajfit/vuex-action-patcher/branch/master/graph/badge.svg)](https://codecov.io/gh/alajfit/vuex-action-patcher)
[![npm](https://img.shields.io/npm/v/vuex-action-patcher.svg) ![npm](https://img.shields.io/npm/dm/vuex-action-patcher.svg)](https://www.npmjs.com/package/vuex-action-patcher)

> Add tools to your Vuex action context

<p align="center">
    <img width="200" height="200" src="./docs/assets/vue.svg" />
    <img width="150" height="160" src="./docs/assets/action.png" />
</p>

## Motivation

I found making tools available to the Vuex action context could be handy for numerous reasons. The library is designed for you to pass the same toolset to all actions from within the context.

* add tools to all actions
* add tools to actions within registered modules
* keep consistent tooling across all actions

## Install

```bash
npm install vuex-action-patcher --save
```

## Usage

### Use in a Vue App
```js
import Vue from 'vue'
import Vuex from 'vuex'
import App from './App.vue'
import vuexActionPatcher from 'vuex-action-patcher'
import { name } from '../package.json'
import moment from 'moment'

Vue.use(Vuex)

const tools = vuexActionPatcher(Vuex, { moment })

const store = new Vuex.Store({
  state: {
    name
  },
  actions: {
    getTime ({ moment }) {
      console.log(moment().calendar())
    }
  },
  plugins: [tools]
})

new Vue({
  el: '#app',
  store,
  render: h => h(App)
})
```

### Use with Dynamic Modules
> main.js
```js
import Vue from 'vue'
import Vuex from 'vuex'
import App from './App.vue'
import vuexActionPatcher from 'vuex-action-patcher'
import { name } from '../package.json'
import moment from 'moment'

Vue.use(Vuex)

const tools = vuexActionPatcher(Vuex, { moment })

const store = new Vuex.Store({
  plugins: [tools]
})

new Vue({
  el: '#app',
  store,
  render: h => h(App)
})
```

> later.js
```js
store.registerModule('myModule', {
  state: {
    name: 'myModule'
  },
  actions: {
    getTime ({ moment }) {
      console.log(moment().calendar())
    }
  }
})
```

### Use in a Nuxt App
> Under `store/index.js`
```js
import Vuex from 'vuex'
import vuexActionPatcher from 'vuex-action-patcher'
import moment from 'moment'

const vuexActionPatch = vuexActionPatcher(Vuex, { moment })

const createStore = () => {
  return new Vuex.Store({
    state: () => ({
      counter: 0
    }),
    mutations: {
      increment (state) {
        state.counter++
      }
    },
    actions: {
        getDate ({ moment }) {
            console.log(moment().calendar())
        }
    },
    plugins: [vuexActionPatch]
  })
}

export default createStore
```

---
_Source: https://npm.io/package/vuex-action-patcher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
