okahistory
v0.1.0
Published
![Main](https://github.com/miyanokomiya/okahistory/workflows/Main/badge.svg) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Downloads
11
Readme
okahistory
This is a convenient tool for the features of undo-redo operations.
usage
yarn add okahistory
import type { Reducer } from 'okahistory'
import { useHistory } from 'okahistory'
const state = { count: 0 }
const history = useHistory()
// define your reducers
const reducerA: Reducer<number, number> = {
redo(after) {
const before = state.count
state.count = after
return before
},
undo(before) {
state.count = before
},
}
const { dispatch, createAction } = history.defineReducers({ ACTION_A: reducerA })
// dispatch an action
dispatch(createAction('ACTION_A', 1))
// undo & redo
history.undo()
history.redo()
commnad
# install dependencies
$ yarn install
# lint
$ yarn lint
# test
$ yarn test [--watch]
# build
$ yarn build
publish
Create new release on Github.