# vuex-redo-undo

> a history plugin for vuex that allows you to undo or redo the store history

Latest version **1.0.1** (published 2019-06-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install vuex-redo-undo
pnpm add vuex-redo-undo
yarn add vuex-redo-undo
bun add vuex-redo-undo
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-06-02 |
| First published | 2019-06-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | luoliqiang |
| Maintainers | luoliqiang |
| Keywords | vuex, redo, undo, history |

## Links

- npm: https://www.npmjs.com/package/vuex-redo-undo
- npm.io page: https://npm.io/package/vuex-redo-undo

## Recent versions

- 1.0.1 (latest) — 2019-06-02

## README

# vuex-history

> a history plugin for vuex that allows you to undo or redo the store history.

## installation
``` bash
npm i --save-dev vuex-rado-undo
```
## module
``` bash
import history from 'vuex-redo-undo'
```
## usage
use it as same as vue plugin, and pass the store as a params of plugin.
``` js
import store from './store'
Vue.use(history, store)
```
you must, of course, add the mutation of updatehistory in your vuex store,like this:
``` js
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  mutations: {
    updateHistory (state, data) {
      if (data) {
        // change
        for (let key in data) {
          Vue.set(state, key, data[key])
        }
        // delete
        for (let key in state) {
          if (typeof data[key] === 'undefined') {
            Vue.delete(state, key)
          }
        }
      }
    }
  }
})
export default store
```
whenever you need to create a record of history you need to call the method of `update` manual.
in the majority of cases we need to record the initial history of our application,like:
 ``` js
 mounted () {
    this.$history.update()
 }
 ```
## Api
#### Methods
`update` record the history
`undo` undo the history
`redo` redo the history
`hasUndo` check if has undo steps
`hasRedo` check if has undo steps
## Build Setup

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