Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xujif/vue-immer-store

A vue plugin that uses immer-js as vue's state manager, redo/undo is supported.
https://github.com/xujif/vue-immer-store

Last synced: 17 days ago
JSON representation

A vue plugin that uses immer-js as vue's state manager, redo/undo is supported.

Awesome Lists containing this project

README

        

# vue-immer-store
A vue plugin that uses immer-js as vue's state manager, redo/undo is supported.

### Usage

#### Install
```bash
npm i --save-dev vue-immer-store
```

#### API

```typescript
import { useImmer } from 'vue-immer-store'

const { state, redo, undo, canRedo, canUndo } = useImmer({ count: 1 })

// update draft state directly
produce(r => {
r.count = 1
})

// update by return value, primitive is supported
produce(() => {
return {
count: 2,
}
})

/* template

{{state.count}}

*/
```